[Python-ideas] The @update operator for dictionaries
Steven D'Aprano
steve at pearwood.info
Sat Mar 9 11:49:14 EST 2019
On Sat, Mar 09, 2019 at 04:34:01PM +0000, Jonathan Fine wrote:
> There are (many) numbers between 1 and infinity. If a programmer
> defines __at_python__ on type(guido) then guido at python will have
> semantics.
It already has meaning: it calls the @ operator with operands "guido"
and "python".
> 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
> good.
The interpreter doesn't distinguish between "a @ b" and "a at b".
Spaces around operators are always optional.
The last thing we're going to do is repeat Ruby's design mistake of
making code dependent on spaces around operators. Define a function in
Ruby with a default value:
def a(x=4)
x+2
end
and then evaluate the expressions:
a + 1
a+ 1
a+1
a +1
The results you get will be 7, 7, 7 and 3.
--
Steven
More information about the Python-ideas
mailing list