Newbie question
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Nov 14 04:34:21 EST 2002
"Firdaus Janoos" <fjanoos at yahoo.com> wrote in
news:aqvlp2$rtb$1 at tilde.itg.ti.com:
> I know this is kind of dumb, but i cant figure out how to execute
> a .py
> file (not a module - a pgm ) from IDLE. I am unable to "load" the
> file. The IDLE menu has options for
> File/Open
> and File/Open Module
> and neither of these open and load the file I want to execute. They
> just exhibit some pretty strange behavior.
> Can anyone give me a clue ?
File/Open lets you open a script or a module for editing by specifying its
filename.
File/Open Module lets you open a module for editing by specifying the name
of the module. For this to work the module source has to be in a directory
in sys.path.
Once you have a module or script open for editing, 'Edit/Run script' lets
you run the currently open file as a script (even if you opened the file
using Open Module).
If you just want to run a script then it is often easiest to start it from
outside Idle, even if you are using Idle to edit it at the time. Just save
and then start the script from your usual command line or gui shell.
One word of warning, Idle doesn't run the script in a separate process, so
after you have run a script once, any variables it created will be left
lying around. This can have implications when you run the script again.
This is especially true if the script is a unit test which imports the
module that it tests as the module to be tested will not be reloaded unless
you or your script do it explicitly. Also, should the script lock up or
crash the Idle environment will go with it.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list