One last shot at the Augmented Assignment PEP

Fredrik Lundh effbot at telia.com
Thu Sep 14 17:57:07 EDT 2000


warren wrote:
> I've always been tempted to tell people to think of "=" as binding, not
> assignment, but even in versions <= 2.0, it didn't always mean that:
> 
> a = [0]
> a[0] = 1
> 
> No symbol rebinding here, although we have copied a reference.

well, it's only binding if the assignment target is
a simple name.

all other assignments are just nice ways to write
certain method calls:

    a[0] = 1
    a.__setitem__(0, 1)

    a.x = 1
    a.__setattr__("x", 1)

:::

> In short, the amount of time we spend explaining things to people who didn't
> read the instructions, and the consistency of interpretation of "=", and what
> we have to know haven't changed much.  But now some things can be expressed
> more clearly, and in some cases, implemented more effieciently.

couldn't have said it better myself.

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->




More information about the Python-list mailing list