On Tue, 09 Oct 2007 18:08:34 +0000, Steven D'Aprano wrote:

>>>> L = []
>>>> id(L)
> 3083496716L
>>>> L += [1]
>>>> id(L)
> 3083496716L
> 
> It's the same L, not rebound at all.

It *is* rebound.  To the same object, but it *is* assigned to `L` and not
just mutated in place.

In [107]: class A:
   .....:     a = list()
   .....:

In [108]: class B(A):
   .....:     pass
   .....:

In [109]: B.a += [42]

In [110]: A.a
Out[110]: [42]

In [111]: B.a
Out[111]: [42]

If it was just mutation then `B.a` would have triggered an `AttributeError`.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to