[Python-Dev] IDLE local scope cleanup
Patrick K. O'Brien
pobrien@orbtech.com
Wed, 13 Nov 2002 13:55:26 -0600
How does IDLE clean up it's local scope on startup? By that I mean the
following. When you start IDLE and do a dir() you get the following:
Python 2.2.2 (#1, Oct 28 2002, 17:22:19)
[GCC 3.2 (Mandrake Linux 9.0 3.2-1mdk)] on linux2
Type "copyright", "credits" or "license" for more information.
GRPC IDLE Fork 0.8.9
>>> dir()
['__builtins__', '__doc__', '__name__']
>>>
Only three items are returned by dir(), just like in the regular Python
interpreter. Now I know how IDLE sets this up in its code, but I can't
seem to achieve the exact same results with PyCrust. And when I add a
print statement to the IDLE source code (PyShell.py):
class ModifiedInterpreter(InteractiveInterpreter):
def __init__(self, tkconsole):
self.tkconsole = tkconsole
locals = sys.modules['__main__'].__dict__
print locals.keys()
InteractiveInterpreter.__init__(self, locals=locals)
self.save_warnings_filters = None
I can see that locals contains a bunch of stuff (well, one extra item
when you run idle.py, and a bunch of stuff when you run PyShell.py),
similar to what I see in PyCrust. So where does it all go by the time
IDLE is up and running? Where does locals get "cleaned up"? Every one
of my hunches has lead to me down a dead end. I give up! Please help.
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------