A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-June/004693.html below:

[Python-Dev] Augmented assignment

[Python-Dev] Augmented assignmentPaul Prescod paul@prescod.net
Fri, 16 Jun 2000 21:22:08 +0200
Many people have given examples where the augmented assignment version
is substantially more readable. Others have argued that it is more
explicit in that it says *exactly what you mean* rather than using a
more general operator in a specific (common) situation. Another
important argument is that augmented assignment allows *in place*
assignment for some types. That's really important for matrix math etc.

 All of these arguments convince me that this is not a simple matter of
"another notation for what we already do."

> Augmented assignments are unPythonic because they don't add any new
> functionality to the language.  From what I've seen, all people,
> who ever missed it, were experienced C-programmers.  

That's true, but we should not be ashamed to steal good ideas from other
languages. Probably the only people who would miss __getattr__ would be
SmallTalk programmers and the original proponents of the various
operator overloading features may well have come from C++.

> ...
> This feature must be learned
> additionally, where normal assignment are easiely understood from
> school mathematics.  

Not really!

a=a+1 is totally illegal in basic arithmetic.

> It also introduces many more possibilities to make
> subtle mistakes, since it is not obvious (at least to No-C-programmers)
> when and how often the index expression will be valuated.  

As I understand the proposal, the function will be called exactly as
many times as it is printed in the source code:

> versus
>         foo[bar()] += bar()
>         print foo

Presumably bar() gets called twice.

The only argument against this that is persusaive to me is that it makes
the core Python language larger and thus a (little) harder to learn. My
impression is that the design of the feature has been well done.

My personal opinion is that the cost in education probably outweighs the
benefits in clarity but others who work a lot with matrices etc. would
probably have a different view.

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
"Music is the stuff between the notes." - Claude Debussy




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4