Class Variable Access and Assignment

Donn Cave donn at u.washington.edu
Thu Nov 3 11:57:10 EST 2005


In article <dkd7lv$j7s$1 at wake.carmen.se>,
 Magnus Lycka <lycka at carmen.se> wrote:
...
> On the other hand:
> 
>  >>> class C:
> ...     a = [1]
> ...
>  >>> b=C()
>  >>> b.a += [2]
>  >>> b.a
> [1, 2]
>  >>> C.a
> [1, 2]
> 
> I can understand that Guido was a bit reluctant to introduce
> += etc into Python, and it's important to understand that they
> typically behave differently for immutable and mutable objects.

As far as I know, Guido has never added a feature reluctantly.
He can take full responsibility for this misguided wart.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list