Augmented Assignement (was: Re: PEP scepticism)

Fredrik Lundh fredrik at pythonware.com
Tue Jul 3 03:17:53 EDT 2001


Carsten wrote:

> Well, the Python world before augmented assignment was quite simple:
> Operators never changed the objects they acted on.

nothing prevents __add__ from changing the objects.

> Now we have augmented assignments.  x=+y _can_ change the object
> bound to x, depending if x is mutable or immutable.

has nothing to do with mutability, and all to do with how the
__iadd__ method is implemented:

    + is an alias for __add__
    += is an alias for __iadd__

as for all other operators, the exact semantics are up to the
type/class implementation.

</F>





More information about the Python-list mailing list