Clearing pythonwin environment

Network Ninja jeremiah.bess at gmail.com
Sat Jun 24 00:16:01 CEST 2006


Scott David Daniels wrote:
>      keep = set(['__builtins__', '__doc__', '__name__',
>                  'pywin', 'keep', 'item', 'globs'])  # Faster to test
>      globs = globals()
>      for item in dir():
>          if item not in keep:
>              del globs[item]
>      del globs, item

This did not work, it gave an error saying "NameError: name 'globs' is
not defined".

However, Steven's del globals()[item] did the trick perfectly. Thanks a
million for the replies, both of you.

So can you explain the [] after globals()? How does that work? The help
docs don't mention anything about that in the function.




More information about the Python-list mailing list