RuntimeError: dictionary changed size during iteration

Batista, Facundo FBatista at uniFON.com.ar
Thu Jan 20 07:28:41 EST 2005


[Robert Brewer]

#- > >>> [e for e in vars()]
#- > Traceback (most recent call last):
#- >   File "<stdin>", line 1, in ?
#- > RuntimeError: dictionary changed size during iteration
#- > >>> e = None
#- > >>> [e for e in vars()]
#- > ['e', '__builtins__', 'rlcompleter', '__file__', '_[1]', 
#- > 'atexit', '__name__',
#- > 'readline', '__doc__']
#- 
#- But not unexpected, since vars() returns a dictionary, and 
#- binding 'e'
#- changes that dictionary while you are iterating over it. Try either:

For me, the point is: vars() returns the local variables as a list or is a
generator?

In the docs don't say nothing about this.

If it returns a list, it should NOT raise an error; if it's a generator, the
error is fine.

.    Facundo

Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/


  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
ADVERTENCIA.

La información contenida en este mensaje y cualquier archivo anexo al mismo,
son para uso exclusivo del destinatario y pueden contener información
confidencial o propietaria, cuya divulgación es sancionada por la ley.
Si Ud. No es uno de los destinatarios consignados o la persona responsable
de hacer llegar este mensaje a los destinatarios consignados, no está
autorizado a divulgar, copiar, distribuir o retener información (o parte de
ella) contenida en este mensaje. Por favor notifíquenos respondiendo al
remitente, borre el mensaje original y borre las copias (impresas o grabadas
en cualquier medio magnético) que pueda haber realizado del mismo.
Todas las opiniones contenidas en este mail son propias del autor del
mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones
Personales S.A. o alguna empresa asociada.
Los mensajes electrónicos pueden ser alterados, motivo por el cual
Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación
cualquiera sea el resultante de este mensaje.
Muchas Gracias.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050120/a7cd2514/attachment.html>


More information about the Python-list mailing list