On Fri, Jul 10, 2020 at 08:23:09AM -0400, Ricky Teachey wrote:
> My mind instantly went to the idea of using this syntax as a way write
> single line mathematical function definitions:
>
> f[x, y] = x + y
This won't work, because the right hand side will be evaluated first.
The above is legal syntax today, and roughly equivalent to:
value = x + y
index = (x, y)
f.__setitem__(index, value)
except of course no such local variables value and index are created.
But you can see why that cannot be used to define a function: the right
hand side is evaluated, and all your `__setitem__` method will see is
the value of x + y, not the fact that it is "x + y".
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/6W4WVUUKJ2RVJMLOJNXKJQ7EG7V22S3V/
Code of Conduct: http://python.org/psf/codeofconduct/