On Sun, Aug 30, 2020 at 8:36 PM Random832 <random...@fastmail.com> wrote:

> The thing that bothers me with new dunders is - can it be done in such a
> way that *all* possible ways of calling it with only positional arguments
> behave the same as presently when the old one is defined, and an intuitive
> way with the new one, without requiring the calling bytecode to know which
> signature is going to be used?
>

Probably not. (And knowing the signature is impossible -- there are too
many layers of C code between the bytecode and the function object being
called.) This is why I ended up with the simplest proposal possible --
keyword args get added to the end of `__getitem__` and `__setitem__`,
ensuring that `d[1, k=3]` is like `d[1]` + keyword, not like `d[1,]` +
keyword.

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/THSSBSNK2LDCPN7TMHP4X5P4QD4J3J6K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to