On Apr 22, 2005, at 12:21 AM, Bob Ippolito wrote:


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.




PyOXIDE has the option of running as an internal interpreter or an external interpreter. Running internally allows for more interactive development since you can spawn interactive interpreters that run in the same name space (so you can work with the results of executing), and the environment is then persistent between runs. You can also run a script internally "as __main__" or not (i.e, have the module name set to "__main__" so the 'if __name__=="__main__"' works).

If you run externally, you, of course, get __main__, but you can't easily investigate the result environment (unless you enable debugging and put a breakpoint at the last line of code, at which point you can show a console interpreter which executes (remotely) in that environment).

Both modes support full debugging capabilities, though the "internal" version is faster (and a little more flexible) since it doesn't need to do all the rpc/object proxy stuff...


Glenn Andreas                      [EMAIL PROTECTED] <http://www.gandreas.com/> oh my! quadrium | build, mutate, evolve | images, textures, backgrounds, art

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to