On 2020-06-24 13:37, Antoine Pitrou wrote:
On Wed, 24 Jun 2020 21:54:24 +1200 Greg Ewing email@example.com 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.
Could the name be omitted when you're not interested in the value?
case Point(?, 0):
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()):