Augmented Assignement (was: Re: PEP scepticism)

Thomas Wouters thomas at xs4all.net
Mon Jul 2 15:22:38 EDT 2001


On Mon, Jul 02, 2001 at 11:17:24AM -0400, Fran?ois Pinard wrote:

> Fuzziness in this area does not bring us anything, really.  If you really
> want a method to extend an mutable, spell it out as we always did, similar
> to list.append(), say, but leave "+" and "+=" alone.

I think you misunderstand. This is and always was *my* intent for augmented
assignment, as well as *Guido*'s intent, as well as the intent of all but
one of the people who reacted to the augmented assignment PEP back when it
was written (for Python 2.0). I discussed this exact subject explicitly with
Guido, and he was quite clear in what he wanted augmented assignment for. It
works this way. It isn't going to change unless you come with arguments to
convince Guido, and he has already heard all arguments in this thread --
from me, before the implementation was checked in. I doubt he would have
gone for a pure syntactic sugar version of augmented assignment no matter
what I'd have said :)

Changing the implementation two releases *after* the fact is going to
require a lot more arguments, and more than just arguments to boot. I have
yet to find a case where the augmented assignment semantics trick newbies,
even newbies that are baffled by the three-scope-rule (which we still have,
despite nested scopes,) mutable-default-arguments, 'list.append()' (and
'list.sort()' and other mutating methods) not returning the list itself, and
more. Once they grasp the difference between mutable and immutable values,
and they need to do this at one time or another anyway, they also understand
the exact semantics of augmented assignment.

This thread reminds me a great deal about whether generators should be
defined using 'def' or 'generate' -- it took me one (1) generator to realize
how natural it was with def, and most (not all) counterarguments were
basically trying to tell me I was wrong to feel that way :-)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list