Augmented Assignement (was: Re: PEP scepticism)

Bernhard Herzog bh at intevation.de
Fri Jun 29 17:51:07 EDT 2001


Guido van Rossum <guido at python.org> writes:

> Bernhard Herzog <bh at intevation.de> writes:
> 
> > Augmented assignment doesn't actually offer anything that couldn't have
> > been done with explicit method calls, at least as far as in-place
> > modification is concerned, because under the covers it actually is a
> > method call. Explicit is better than implicit.

To put this into the right context: I wrote that to illustrate that
augmented assignment offers nothing in terms of polymorphism that wasn't
already there.

> Sorry, I don't understand why people can seriously argue *against*
> augmented assignment.  It just baffles me.  What kind of Spartan
> upbringing did you have?  Scheme?  Really, I just don't get it. 

That paragraph quoted above makes my position on augmented assignment
appear much more radical than it actually is. Augmented assignment does
have it's advantages but I don't think that those outweigh the
disadvantages. Now that they're in the language I use them occasionally.

> This was by far the most asked-for feature ever!

IMO, that is not necessarily an argument in favor of adding a certain
feature. My recollection is that every time this came up on c.l.py it
was explained that there are some design issues with augmented
assignment in python which don't appear in C or C++ because of
different semantics. That x += 1 should be equivalent to x = x + 1 if x
is a number is obvious whereas what x += [1] should mean for a list is
not. IIRC for most users that was good enough so they didn't pursue this
further.

  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                               http://mapit.de/



More information about the Python-list mailing list