On Wed, Jun 24, 2020 at 5:23 AM Eric Wieser <wieser.eric+numpy@gmail.com> wrote:
In regards to https://www.python.org/dev/peps/pep-0622/#alternatives-for-constant-value-pattern, was this alternative considered?
match obj:
    case SomeClass(field := _):  # is this already allowed by the PEP?
    case some_constant:  # my proposal: do not require `.some_constant` here
    case (other := _):  # is this already allowed by the PEP? If so, do we need the extra `case other:` spelling?

It seems like `:=` already provides all the necessary syntax for distinguishing bindings from constants, admittedly at the cost of 6 characters per binding (eg `Point(x := _, y := _)`) - so introducing additional syntax seems unnecessary.

In languages that have pattern matching, it is the primary way to extract pieces of a compound data structure into individual variables. For the use cases where match would be a good fit in Python, the same will be true. So using your proposed syntax here is too verbose to consider.
If this was considered but rejected for verbosity concerns, it would be nice to see it mentioned in the rejected alternatives section.

We can't discuss every single idea in that section. I don't think anyone else has proposed this, so I don't think it needs to be discussed for posterity. There are plenty of better ideas in this thread that deserve a mention there.

--Guido van Rossum (python.org/~guido)