PATCH: Augmented assignment
Warren B. Focke
moron at Glue.umd.edu
Fri Jun 9 14:39:19 EDT 2000
David said:
>On Fri, 9 Jun 2000 16:39:38 +0200, Thomas Wouters <thomas at xs4all.net>
>wrote:
>
>>As promised, here is my patch to add augmented assignment (+=, -= and
>>family) to Python. It's still Work In Progress, and probably requires
>>a rewrite of some magnitude before Guido will accept it.
>Why would the Python community want this?
[...]
>And it's not like it adds new functionality
But it does. Accessing an attribute of an object or an item in a
container type can invoke arbitrary code, with arbitrarily freakish
side effects. Evaluating x[17] might suck up hours of CPU time and
gibibytes of RAM, redefine builtin functions, launch the missiles, or
annoy your mother. Having all of these things happen once, as in
x[17] += 1, is much preferable to, and potentially significantly
different from, having them happen twice, as in x[17] = x[17] + 1.
It's not just syntactic sugar that
>saves the lazy programmer a whopping one or two keystrokes.
Warren Focke
--
If you feel that you have both feet planted on level ground, then the
university has failed you. -Robert Goheen, President, Princeton University
More information about the Python-list
mailing list