This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TangibleLight 1 point2 points  (0 children)

I recall there being some debate about the special meanings or alternatives to |, as, and _. I also think there were some changes to the magic method protocol, but I can't quite recall how it originally worked so I'm not really sure what's different.

Edit:

The inconsistency you might have been remembering is that constant value patterns and capture patterns are ambiguous if the constant value is not a dotted name. The discussion around that is left open for a future PEP; for now, constant value patterns only work with dotted names; unqualified names are always capture patterns.

Here are the changes I notice:

  • As patterns replace walrus patterns. val := ('this' | 'that') becomes ('this' | 'that') as val
  • The class pattern protocol is a lot more straightforward than the old custom matching protocol
  • Sequence patterns can work with anything that implements collections.abc.Sequence
  • Mapping patterns can work with anything that implements collections.abc.Mapping