One last shot at the Augmented Assignment PEP

Bob Alexander balexander at rsv.ricoh.com
Wed Sep 13 14:15:42 EDT 2000


Seems as though most members of this list are pretty happy with the
recent Augmented Assignment PEP definition.

As a proponent of *true* augmented assignment, though, I suggest we
rename that new feature in Python to something more appropriate to the
definition. Like "sometimes-augmented sometimes-assignment". Or "totally
new operators having little to do with assignment".

Note that in

    a = []
    a += [33]

neither "+" (list concatenation) nor "=" (assignment) are performed
<wink>*.

Furthermore, in

    a = []
    b = a
    a += [33]

b changes. Neither "+" (list concatenation) nor "=" (assignment), would
affect b at all.

Since neither assignment nor the operation suggested by the binary
operator bundled with the "=" take place in the above examples, and
since new side effects occur that would not happen in pure augmented
assignment, how could it be appropriate to call it such?

And then there's

    tup = ()
    lst = []
    tup += (33)
    lst += [33]

The last two lines look about the same but have different semantics! In
pure augmented assignment the semantics would be parallel, and would be
exactly what is suggested by the two characters of the "+=" operator.

Bob

* <wink>(TM) used without permission.




More information about the Python-list mailing list