This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients amaury.forgeotdarc, belopolsky, djc, eric.araujo, ysj.ray
Date 2010-07-21.14:35:18
SpamBayes Score 0.00012515402
Marked as misclassified No
Message-id <AANLkTimVhA5aso3TYezM5nFC7JwOygt5ku6R5I2lzkR-@mail.gmail.com>
In-reply-to <1279692578.11.0.528380218473.issue9314@psf.upfronthosting.co.za>
Content
On Wed, Jul 21, 2010 at 2:09 AM, Ray.Allen <report@bugs.python.org> wrote:
..
> Does this means "a += b" is not the same as "a = a + b"?

For immutable a, the two are practically the same, for mutable, they
are necessarily different.   This is explained in __iadd__
documentation:

"""
These methods are called to implement the augmented arithmetic
assignments (+=, -=, *=, /=, //=, %=, **=, <<=, >>=, &=, ^=, |=).
These methods should attempt to do the operation in-place (modifying
self) and return the result (which could be, but does not have to be,
self). If a specific method is not defined, the augmented assignment
falls back to the normal methods. For instance, to execute the
statement x += y, where x is an instance of a class that has an
__iadd__() method, x.__iadd__(y) is called. If x is an instance of a
class that does not define a __iadd__() method, x.__add__(y) and
y.__radd__(x) are considered, as with the evaluation of x + y.
"""  http://docs.python.org/reference/datamodel.html?#object.__iadd__

> I'd think this can be seen as a pitfall for python.

No.  Please see PEP 203 for the rationale.
http://www.python.org/dev/peps/pep-0203/
History
Date User Action Args
2010-07-21 14:35:21belopolskysetrecipients: + belopolsky, amaury.forgeotdarc, djc, eric.araujo, ysj.ray
2010-07-21 14:35:19belopolskylinkissue9314 messages
2010-07-21 14:35:18belopolskycreate