Browse by Topic
Popular
Popular Posts
Latest
Latest Posts
Python Dunder Methods: Practical Usage and Pitfalls
Learn how Python dunder methods control object behavior, operator overloading, and context management with practical examples and common pitfalls.
Python Magic Methods: How They Work and When to Use Them
python magic methods: Learn how Python magic methods (dunder methods) control object behavior, operator overloading, and lifecycle hooks with practical examples.
Python Dataclass vs Namedtuple: Key Differences
Compare Python's dataclass and namedtuple: mutability, syntax, defaults, performance, and when to use each for data containers.
python namedtuple vs dataclass: When to Use Each
Python's namedtuple and dataclass both create lightweight objects with named fields. They differ in mutability, type hints, memory footprint, defaults, and extensibility; see when to use each.
Python Dataclass vs Class: When to Use Each
Compare Python dataclasses and regular classes, including syntax, behavior, and when each fits better in your code.
Using __post_init__ in Python Dataclasses
Learn how to use __post_init__ in Python dataclasses to validate fields, compute derived values, and customize initialization behavior.
Python Dataclass Inheritance: Syntax and Common Pitfalls
Learn how Python dataclass inheritance works: field collection, default-value ordering, keyword-only fields, overrides, and __post_init__ behavior.
Using Python dataclass slots for memory efficiency
Learn how Python dataclass slots reduce memory overhead and can speed up attribute access, and understand the tradeoffs and limitations.
Python Dataclass eq: Controlling Equality and Hashing
The eq parameter in Python dataclasses controls __eq__ generation, affects __hash__, and interacts with frozen and order. See when to use eq=False for identity equality.
Customizing Python Dataclass Repr Output
Learn how Python dataclass repr works, how to exclude fields, write a custom __repr__, and weigh performance and logging tradeoffs.