[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020年6月24日 05:47:31 -0700

On 2020年6月24日 21:54:24 +1200
Greg Ewing <[email protected]> wrote:
> On 24/06/20 5:20 am, Antoine Pitrou wrote:
> > suddently `Point(x, 0)` means something entirely
> > different (it doesn't call Point.__new__, it doesn't lookup `x` in the
> > locals or globals...). 
> 
> This is one reason I would rather see something explicitly marking
> names to be bound, rather than making the binding case the default.
> E.g.
> 
> case Point(?x, 0):
> 
> This would also eliminate the need for the awkward leading-dot
> workaround for names to be looked up rather than bound.
That looks quite a bit better indeed, because it strongly suggests
that something unusual is happening from the language's POV. Thank you
for suggesting this.
> One other thing that the PEP doesn't make clear -- is it possible
> to combine '=' and ':=' to match a keyword argument with a sub
> pattern and capture the result? I.e. can you write
> 
> case Spam(foo = foo_value := Blarg()):
Yuck :-S
Regards
Antoine.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/6PHXAGXL3Y6HTSH7JAPHVO2ABPAYJOWO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to