[Tutor] Re: python22

Lee Harr missive at hotmail.com
Wed Aug 6 22:41:58 EDT 2003


>I have python22 installed.
>I am able to use IDLE (GUI) to RUN SCRIPTS.
>I can also RUN saved files from a MS DOS command line window.
>I don't know what the PYTHON(command line) window that is available in
>PYTHON22 drag down menu used for. when I open this command line it starts
>with >>> and I can not run saved programs with it.how this command line
>used?
>

It is pretty much the same thing as you would get by choosing
Run -> Python Shell
from the IDLE window.

It is the Python interactive interpreter. You can type python
statements at that >>> prompt.

You can run programs from that prompt... but you have to
import them first.

Let's say you have a file foo.py

#foo.py
def bar(n):
    print n

if __name__ == '__main__':
    bar('module was run, not imported')

#end foo.py

If I run the program:
>python foo.py
module was run, not imported


But then you could in your Python Shell...

>>>import foo
>>>foo.bar('a test')
a test


Of course, foo.py needs to be on your sys.path for that to work....

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail




More information about the Tutor mailing list