RuntimeError: dictionary changed size during iteration

Robert Dailey rcdailey at gmail.com
Mon Dec 8 22:10:00 EST 2008


On Dec 8, 6:26 pm, Terry Reedy <tjre... at udel.edu> wrote:
> Robert Dailey wrote:
> > stuff = vars()
>
>  >>> vars() is globals()
> True
>
> > for key in stuff:
>
> You just changed globals, which is aliased as stuff.
> Stuff changes.
>
> >     print( key, '--', stuff[key] )
>
> > I get the following error message:
> > ('CopyEmotionFX', '--', <function CopyEmotionFX at 0x0205BF70>)
> > Traceback (most recent call last):
> >   File "C:\IT\work\jewett\depends.py", line 12, in <module>
> >     for key in stuff:
> > RuntimeError: dictionary changed size during iteration
>
> > Why is this happening?
>
>

How am I changing globals()? I'm simply iterating the keys in the
dict. Can someone explain what is going on please?



More information about the Python-list mailing list