Newbie: tuple list confusion.

John Roth newsgroups at jhrothjr.com
Mon Sep 13 15:59:00 CEST 2004


"Alex Martelli" <aleaxit at yahoo.com> wrote in message 
news:1gk1n7i.2du2ju1d38wwgN%aleaxit at yahoo.com...
> Elaine Jackson <elainejackson7355 at home.com> wrote:
>
>> In addition to what you've found out already, there is another difference
>> that, to my mind, is of paramount importance; namely, the fact that an
>> augmented assignment (a+=b) is actually not an assignment at all. An
>> actual assignment (a=a+b) binds the name "a" to a new object, while a
>> so-called augmented assignment mutates the object a itself.
>
> Ah, careful there: augmented assignment (nothing "so-called" about it;-)
> mutates the object and THEN assigns ("re-binds" if you want to get
> technical) the name or other slot holding the object.

I've never understood why it does that. If you have a mutable object
that is updated, then the rebinding makes no sense whatsoever.
The problem is that it's not just confusing, I think I  have a
reasonable expectation that if it fails, it fails atomically.

John Roth

> Alex 





More information about the Python-list mailing list