3 ms·
> My intuitions come from C and C++, so "+=" should always modify a single object (in C lingo it would be "lvalue") in place. Storing the result somewhere else
by cecilpl2 4y ago
> My intuitions come from C and C++, so "+=" should always modify a single object (in C lingo it would be "lvalue") in place. Storing the result somewhere else than the left side of "+=" is counterintuitive to me.
I thought of this as though the list A.b was marked static - then any modification of b through any instance of A modifies the shared static member
>>> class A:
... b = [1,]
...
>>> obj = A()
>>> obj.b.append(2)
>>> A.b
[1, 2]
>>> foo = A()
>>> foo.b
[1, 2]
>>>