Augmented Assignment (was: Re: PEP scepticism)

Remco Gerlich scarblac at pino.selwerd.nl
Fri Jun 29 05:15:50 EDT 2001


Paul Prescod <paulp at ActiveState.com> wrote in comp.lang.python:
> Bruce Sass wrote:
> > ...what was a wart becomes a feature.
> 
> That was a lot of effort to understand a typing shortcut. It's somewhat
> unpythonic to trade a long explanation for a bit less typing.

But augmented assignment isn't about a bit less typing.

For one thing, A *= 2 can be implemented a lot more efficiently than A = A*2,
in some cases.

Also really_long_variable_name += 1 is more clear than
really_long_variable_name = really_long_variable_name + 1.

The difference between mutable and immutable types may look strange at
first, but in my opinion it's exactly the right pragmatical choice.

-- 
Remco Gerlich



More information about the Python-list mailing list