#dataclasses

[ 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
1 week ago
Web frameworks

Episode #278: PyCoder's Weekly 2025 Top Articles & Hidden Gems - The Real Python Podcast

fromInfoWorld
2 months ago
Python

How to use Python dataclasses

Dataclasses automatically generate common class boilerplate (constructors, representation, and comparisons) from declared fields, reducing repetitive code and errors.
fromGlyph
8 months ago
Bootstrapping

Stop Writing `__init__` Methods

Dataclasses in Python 3.7 simplified the creation of classes, making it easier to represent data structures without complex initialization methods.
fromRealpython
1 week ago
Web frameworks

Episode #278: PyCoder's Weekly 2025 Top Articles & Hidden Gems - The Real Python Podcast

Python
fromInfoWorld
1 month ago

Python vs. Mojo (and Java, Go, Rust, and .NET)

Mojo, alternative data-science languages, Python dataclasses, and a new PyTorch-related distributed-processing framework are current focal points for Python practitioners.
[ Load more ]