[Pythonmac-SIG] Re: Weird import problem with PythonIDE on Mac
(was 'import problem')
Bob Ippolito
bob at redivi.com
Fri Apr 22 07:21:22 CEST 2005
On Apr 21, 2005, at 9:06 PM, Chris Smith wrote:
> ###
> def y1():
> pass
> def foo():
> from __main__ import y1
> pass
> foo()
> ###
>
> Here is a version of the code, stripped of the timeit code. The above
> segment exhibits the same symptoms as the previously submitted one.
>
> Even though I am running this as "__main__" it behaves as though it is
> not __main__. i.e. if I run this with pyOxide without the 'run as
> __main__' option, it generates the same ImportError ('Can't import
> y1') as it does when run in the PythonIDE.
>
> In the pythonIDE it generates the error whether the 'run as __main__'
> option is on or off. As a test of that option, I verified that the
> following code only runs when the __main__ option is on and it worked
> as expected:
The issue probably lies with the fact that (definitely) PythonIDE and
(probably) PyOXIDE have the dumbest possible implementation of an
interactive interpreter. They use the *same interpreter* that runs the
IDE itself. Since the module namespace is flat, there can only be one
__main__, and it belongs to the IDE. This is the least of the issues
you will experience when using such an interpreter.
Wing and IDLE don't have this problem, last I checked. Other than
that, I have no idea which IDEs are stupid and which are not.
-bob
More information about the Pythonmac-SIG
mailing list