Running python on unix
sik0fewl
xxdigitalhellxx at hotmail.com
Fri Mar 28 17:04:36 EST 2003
kpatrick1979 wrote:
> Hi,
>
> 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!
>
> Thanks,
> K
The thing to do is to put this script into a file, ie. amount.py
After creating the file run: python amount.py
Alternatively, after putting this into a file add #!/usr/bin/env python
as the first line of you program. Save the file and exit. Now do "chmod
755 amount.py". These two things together will make the file executable.
Now just do ./amount.py to run the program.
--
Ryan
More information about the Python-list
mailing list