List of declared variables in interactive Python session?

Peter Hansen peter at engcorp.com
Sun Jul 20 15:18:19 EDT 2003


"Raymond Arthur St. Marie II of III" wrote:
> 
> >>> vars( )
> 
> {'d': 'pywin', '__builtins__': <module '__builtin__' (built-in)>, '__name__':
> '__main__', 'pywin': <module 'pywin' from
> 'C:\PYTHON22\lib\site-packages\Pythonwin\pywin\__init__.pyc'>, '__doc__': None}
> 
> >>> for v in vars(): print v
> ...
> 
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> RuntimeError: dictionary changed size during iteration

for v in vars().copy(): print v

works fine...

-Peter




More information about the Python-list mailing list