Class v. Instance variables in Python

Zane Selvans zane at ideotrope.org
Mon Nov 10 17:47:50 EST 2008


Joe Strout <joe <at> strout.net> writes:

> How are you creating your list?  You need to make sure that each  
> instance creates its very own list object, something like:
> 
>    self.foo = []
> 
> rather than grabbing a reference to some shared list instance, such as  
> one defined as a default argument to your __init__ method.

Ah!  Yes, that's it.  Gah, this has been driving me nuts all day.  Thanks!





More information about the Python-list mailing list