Running python on unix

Peter Hansen peter at
Fri Mar 28 23:03:14 CET 2003

kpatrick1979 wrote:
> I am a brand new user learning python for a programming languages
> class.  I am trying to use the practice tutorial to mimic the
> following if-statement exercise:
> >>> x = int(raw_input("Please enter an integer: "))
> >>> if x < 0:
> ...      x = 0
> ...      print 'Negative changed to zero'
> ... elif x == 0:
> ...      print 'Zero'
> ... elif x == 1:
> ...      print 'Single'
> ... else:
> ...      print 'More'
> ...
> However, after I enter the first line of code (i'm using the Python
> command line programming that you can get from the web) I immediately
> get the "Please enter an integer" line -- it doesn't permit me to type
> the rest of the code.  Does anyone know a better way for me to try and
> do this program?  I tried using Unix, but am not having much success
> there either (maybe i'm doing that wrong too)  Help!

This is exactly what it should be doing.  The prompt is for interactive
experimentation, not for creating programs.  What you need is to use
a text editor (even Notepad under windows would work, provided you
are very careful about using TABs properly (but that's another issue)),
then save the file (e.g. as "") and then run it from the
command line using "python" where the command "python" 
comes from have the directory containing the python.exe file properly
set up in your PATH environment variable.

Or you could just use PythonWin, or IDLE, but I can't provide much
help for you there.


More information about the Python-list mailing list