#structural-pattern-matching

[ follow ]
fromMathspp
4 days ago

Recursive structural pattern matching

Structural pattern matching excels at... matching the structure of your objects! For the two examples in this article, we'll be using a number of dataclasses that you can use to build abstract Boolean expressions: from dataclasses import dataclass class Expr: pass @dataclass class And(Expr): exprs: list[Expr] @dataclass class Or(Expr): exprs: list[Expr] @dataclass class Not(Expr): expr: Expr @dataclass class Var(Expr): name: str
Python
Python
fromRealpython
4 months ago

A History of Python Versions and Features - Real Python

Practical overview of Python evolution, major version changes, reasons, and how to use modern features for cleaner, faster, more maintainable code.
[ Load more ]