On Sun., 15 Nov. 2020, 5:25 pm Guido van Rossum, <guido@python.org> wrote:
But Point(x as a) already has a meaning in PEP 634; it’s a positional argument captured in x *and* in a. (Previously spelled as Point(a := x). The phrase ‘as a’ can be added after any pattern to *also* capture it in ‘a’. More typically used as e.g.‘Pattern(x, y) as p’, which captures the first two fields in x and y, and the whole Point in p.

Indeed, the proposed change I'm contemplating for class matching would require that positional matching be opt-in rather than the default.

The default would instead become to check that the named attributes exist, so "Pattern(x, y)" would be short for "Pattern(x=__, y=__)", and you'd have to write "Pattern(x, y, /)" instead to request positional arg matching.

The default behaviour of class patterns would become a lot more like mapping patterns, but working off attribute names rather than keys.

I think that will give an end result that offers the same capabilities as PEP 634, but the proof will be in the reference implementation update.

Cheers,
Nick.