Augmented Assignement (was: Re: PEP scepticism)

Donn Cave donn at
Tue Jul 3 09:43:17 CEST 2001

Quoth Courageous <jkraska1 at>:

| Expecting the change of something  is one thing and observing it's
| incorrectness is another. Be what may about the current implementation
| and future of Python, it is simply wrong that a = a + 1 is evaluated
| differently than a += 1.
| I'm not sure that this will matter much in the scheme of things;
| however, I do know that this behavior will likely always be surprising
| to the uninitiated. The equivalency of a = a + 1 to a +=1 is
| something that I'd wager is the first instinct of programmers
| approaching the form.

Probably, though that might just mean programmers approach from C.

The thing that I like about all this, it's good to hear what
sounds like a consensus that Python programmers need to have
some appreciation of the object/reference/binding/namespace
thing that happens when we assign.  We can't reasonably say
"don't worry, it will just work", we can't pass it off as an
esoteric internal detail, you need to get this model from the
start.  Left to your own devices you might not get it.  If you
don't, you can't accurately predict what your code will do.

If augmented assignments confuse a few people, but the
potential for confusion leads authors and teachers to take
more pains early on, to firm up these notions before +=
can lead folks astray, I predict a net gain.

	Donn Cave, donn at

More information about the Python-list mailing list