Python (and me) getting confused finding keys

Lie Ryan lie.1296 at gmail.com
Tue Dec 22 13:42:51 EST 2009


On 12/23/2009 3:33 AM, John wrote:
> Hi there,
>
> I have a rather lengthy program that troubles me for quite some time. After
> some debugging, I arrived at the following assertion error:
>
> for e in edges.keys():
> 	assert edges.has_key(e)
>
> Oops!? Is there ANY way that something like this can possibly happen?

in a multithreaded program, it's possible another thread erased 'e' 
after the for-loop grabbed it but before the suite is executed.

but often you'll get something like this:
RuntimeError: dictionary changed size during iteration



More information about the Python-list mailing list