Am 17.01.2013 17:21, schrieb Chris Barker - NOAA Federal:
> On Wed, Jan 16, 2013 at 11:34 PM, Matthieu Brucher
> 
>> Of course a += b is not the same as a = a + b. The first one modifies the
>> object a, the second one creates a new object and puts it inside a. The
>> behavior IS consistent.
> 
> Exactly -- if you ask me, the bug is that Python allows "in_place"
> operators for immutable objects -- they should be more than syntactic
> sugar.

They are not -- the "+=" translation is well defined: the equivalents are

a += b
a = a.__iadd__(b)

Now __iadd__ can choose to return self (for mutable objects) or a new object
(for immutable objects).  The confusion about immutables is simply the
"usual" confusion about "=" assigning names, not variable space.

> Of course, the temptation for += on regular numbers was just too much to 
> resist.

And probably 95% of the use of +=/-= *is* with regular numbers.

Georg

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to