At Wednesday 25/10/2006 16:19, trevor lock wrote:
>I've just started using python and have observed the following :
>>class foo:
> a=[]
> def __init__(self, val):
> self.a.append ( val )
It's a common pitfall. As seen just a few days ago:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/99e0b1548ce1de81/35b79173cb8ea105?#35b79173cb8ea105
>I was expecting that everytime I created an instance of the class
>that a unique dictionary was also created, however it seems that
>only one dictionary is created.
>How can I create a new dictionary for each instance?
Notice that you were using a *list* here, not a *dictionary*
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar