On Fri, Feb 28, 2014 at 8:47 AM, Nick Timkovich <prometheus...@gmail.com> wrote:
> On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico <ros...@gmail.com> wrote:
>>
>> On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni <eric.jacob...@gmail.com>
>> wrote:
>> > But, imho, it's far from being a intuitive result, to say the least.
>>
>> It's unintuitive, but it's a consequence of the way += is defined. If
>> you don't want assignment, don't use assignment :)
>>
>> ChrisA
>
>
> Where is `.__iadd__()` called outside of `list += X`?  If the only
> difference from `.extend()` is that it returns `self`, but the list was
> already modified anyway, why bother with reassignment?

Not everything handles += that way. You can't mutate the integer 5
into 7 because someone had 5 in x and wrote "x += 2". So it has to
reassign.

Actually, integers just don't define __iadd__, but the principle applies.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to