[Python-ideas] The @update operator for dictionaries

Jonathan Fine jfine2358 at gmail.com
Sat Mar 9 11:34:01 EST 2019

Steven D'Aprano asked me to explain the difference between
>     a at update=b
>     a at update b

It is the same as the difference between
    a += b
    a + b

The one uses a._iadd__(b), a.__add__(b) and so on. For the other,
replace 'add' by 'at_update', and '+' by '@update'.

By the way, the expressions
   a at update b
   a @update b
are to be equivalent, but
   a @ update b
is something else (and not valid Python).

> Is this supposed to be unique to update, or will there be an infinite
> number of special dunder methods for arbitrary method names?

There are (many) numbers between 1 and infinity. If a programmer
defines __at_python__ on type(guido) then guido at python will have

Steve wrote:
> New syntax which breaks existing code is not likely to be
> accepted without a *really* good reason.

I'd like to see some real-world examples of code that would be broken.
As I recall, most or all of the code examples in the python-ideas
thread on the '@' operator actually write ' @ '. So they would be

And if otherwise a good idea, we can use the from __future__ trick to
maintain compatibility.


More information about the Python-ideas mailing list