How to run script from interpreter?

JustinHJ justinhj at hotmail.com
Thu Jan 18 19:37:00 EST 2001


say you have a script in a file called test.py just type

import test

(you don't need the .py)

As for doing stuff in the script it will execute any commands it encounters.
It's neat to have all your stuff in functions and then have commands at the
bottom to call the functions as needed. This is like a simulated main() from
C.

if __name__ == '__main__': # only run if main program
 DoStuff( )


Rolander, Dan <Dan.Rolander at marriott.com> wrote in message
news:mailman.979855413.16209.python-list at python.org...
> What is the best way to run a python script from within the interpreter?
> What command should I use?
>
> Thanks,
> Dan
>





More information about the Python-list mailing list