Using classes in python

Gabriel Genellina gagsl-py at
Thu Oct 26 01:00:16 CEST 2006

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:

>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! -

More information about the Python-list mailing list