[Tutor] Re: [Pythonmac-SIG] Re: Weird import problem with PythonIDE on Mac (was 'import problem')

Just van Rossum just at letterror.com
Fri Apr 22 10:52:47 CEST 2005


Jack Jansen wrote:

> As always, reading the source provides the answer.
> 
> If you look in PyEdit.py, method Editor.execstring(), you'll see that 
> the only thing "run as __main__" does is set the module name to 
> "__main__". It does *not* change the globals dictionary to __main__.
> 
> I'm not sure about the reasoning behind this, I think Just wanted to 
> make sure that if you had two edit windows open both with "run as 
> __main__" selected they didn't influence each other. On the other hand 
> I can imageine that if you do that, open two windows in __main__ mode, 
> the behaviour you want is exactly that.

It largely as Bob wrote: you can't do this sanely if the script runs in
the same process as the IDE. And what you said: I don't want __main__
scripts to share a namespace. The "Run as __main__" feature is intended
to support the if __name__ == "__main__" idiom, nothing else. Importing
__main__ is a very silly thing to do anyway, if you ask me.

Just


More information about the Tutor mailing list