MemotivaPattern matching

What is a class pattern in match?

Pattern matching

Audio flashcard · 0:16

Nortren·

What is a class pattern in match?

0:16

A class pattern matches an instance of a class and optionally extracts attributes. The syntax uses the class name followed by parentheses with attribute patterns. Class patterns can use positional sub-patterns through the dunder match args attribute. They are powerful for working with data classes and ASTs. ---
peps.python.org