FAQ

"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
Very nice Peter, I didn't see that coming (sad for me). But it amounts to the
same thing, really. Newbies might like to know that you work with a variable
declared specially for this "for" iterater in hopes that you won't stomp all
over a variable you might otherwise clobber.

Only, I love a good one-liner. :-)

Ray --

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 9 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJul 19, '03 at 3:51p
activeJul 22, '03 at 7:07a
posts9
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase