Class initialization

Costin Gament costin.gament at gmail.com
Sun Aug 8 11:16:20 EDT 2010


That looks just like my code. What's the problem?

On Sun, Aug 8, 2010 at 6:13 PM, Jesse Jaggars <jhjaggars at gmail.com> wrote:
>
> Is it possible that you are using a mutable class object? A common
> gotcha is to do something like this:
>
>>>> class foo(object):
> ...   x = []
> ...
>>>> a = foo()
>>>> b = foo()
>>>> a.x.append(123)
>>>> b.x
> [123]
>
> And expect b.x to be an empty list.



More information about the Python-list mailing list