Static variable vs Class variable

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Oct 6 10:25:08 CEST 2007


Bruno Desthuilliers a écrit :
(snip)
> And it is *not* rebound:

Doh. Stupid me. Of course it is - but to a ref to the same object...

  >>> class A:
...     l = []
...
>>> class B(A): pass
...
>>> B.__dict__
{'__module__': '__main__', '__doc__': None}
>>> B.l
[]
>>> B.l += [1]
>>> B.__dict__
{'__module__': '__main__', '__doc__': None, 'l': [1]}
>>>

Thanks Diez for pointing this out. And as far as I'm concerned: time to 
bed :(



More information about the Python-list mailing list