LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   problem with python saving (https://www.linuxquestions.org/questions/programming-9/problem-with-python-saving-888210/)

JAPANBOY 06-24-2011 06:25 PM

problem with python saving
 
hello,

i am having trouble saving my simple program

this is what i wrote

x=raw_input("enter name:")
print "hey" + x
raw_input("Press<enter>")

and everytime when i save this i go to

file
save
JAPANBOY.py
move to desktop
and when i open it there's the black screen and it dissapears in less than a second.
does anybody have any idea what im doing wrong?

by the way im using python 3.2
and the video that im watching it's using an different version.

Tinkster 06-24-2011 06:47 PM

I assume you're doing this in windows? Try running it from a command
line. I don't know how to make a desktop object in windows that will
open a shell and then run your script.



Cheers,
Tink

MTK358 06-25-2011 06:11 AM

It opens the script in a terminal, the script ends, and the terminal closes. Running it from a terminal will fix this (these commands are for Linux):

Code:

cd ~/Desktop
python JAPANBOY.py


bgeddy 06-25-2011 09:03 AM

The problem is your code - raw_input is no longer in python 3. Change raw_input to input in the code and it should work. This is causing a program error which you are not seeing as you are not running the program from the command prompt. This is just quickly opening and closing a terminal session. It's best to run python from the command prompt so errors are shown. When the code is fixed this should work by just launching with a double click.


All times are GMT -5. The time now is 05:20 PM.