newbie question

John Zenger john_zenger at yahoo.com
Thu Mar 2 02:10:33 CET 2006


orangeDinosaur wrote:

> I wrote up a script in my preferred text editor.  It contains maybe ten
> lines of code.  I want to be able to execute those code lines with a
> single command either from the inline mode or from IDLE.  How do I do
> this?  I saved the file (myscript.py) in a folder that I've specified
> in my PYTHONPATH environment variable, and when I type

 From the Python shell, you can use execfile to run a script:

 >>> execfile("joshua.py")

This works regardless of your OS.  The file must be in your Python path. 
  If it isn't, just specify the full path.  Like:

 >>> execfile(r"C:\Code\WOPR\Backdoor\joshua.py")

While viewing your code with IDLE, hit F5 to execute it.



More information about the Python-list mailing list