On Mon, 25 Oct 2021, Chris Angelico wrote:

On Mon, Oct 25, 2021 at 3:47 AM Chris Angelico <ros...@gmail.com> wrote:

On Mon, Oct 25, 2021 at 3:43 AM Jonathan Fine <jfine2...@gmail.com> wrote:

Please forgive me if it's not already been considered. Is the following valid 
syntax, and if so what's the semantics? Here it is:

    def puzzle(*, a=>b+1, b=>a+1):
        return a, b

There are two possibilities: either it's a SyntaxError, or it's a
run-time UnboundLocalError if you omit both of them (in which case it
would be perfectly legal and sensible if you specify one of them).

I'm currently inclined towards SyntaxError, since permitting it would
open up some hard-to-track-down bugs, but am open to suggestions about
how it would be of value to permit this.

In fact, on subsequent consideration, I'm inclining more strongly
towards SyntaxError, due to the difficulty of explaining the actual
semantics. Changing the PEP accordingly.

I think the semantics are easy to specify: the argument defaults get evaluated for unspecified order, in left to right order as specified in the def. Those may trigger exceptions as usual.

Erik
_______________________________________________
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/HYXNABI2ACLVCLQH5TNRDX6WWSHNOING/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to