idle and __name__

Guido van Rossum guido at cnri.reston.va.us
Tue May 18 23:07:00 EDT 1999


"Jeffrey Kunce" <kuncej at mail.conservation.state.mo.us> writes:

> I commonly use the python idiom:
> 
> if __name__=="__main__":
>     runMainRoutine()
> 
> If I use "Run Module" in Idle, this doesn't
> work because it is not the main module.
> 
> Is there some variable or flag I can test to see
> if I'm running a main module from Idle?

No, but in IDLE 0.5 this will be fixed.  The PyShell console will
use the original __main__ module's environment.  The semantics of Run
Module will also change, and there will be an additional Run Script.

This can already be accessed if you have CVS access to the current
Python source tree (see python.org).

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list