Browse by Topic
Popular
Popular Posts
Latest
Latest Python Posts
Python StrEnum: String-Based Enums
Learn how Python 3.11's StrEnum creates string-based enums, simplifies serialization, and improves on the str, Enum mixin pattern.
Python IntEnum: Using Enumerations as Integers
python intenum: Learn how to use Python's IntEnum to combine integer behavior with enumeration safety, including comparisons, serialization, and common pitfalls.
Using Python enum.auto() for Automatic Enum Values
Learn how Python's enum.auto() assigns values, how to customize the generation hook, and when explicit enum values are safer.
Using Python Enum Module for Safer Code
The Python enum module lets you define symbolic constants, improve type safety, and simplify validation in your code.
Using Python Enum Class for Type-Safe Constants
Learn how to use Python's Enum class for type-safe constants: syntax, iteration, auto values, and common pitfalls.
Python Enums: How to Use Enum and IntEnum
Learn how to define and work with Python enums: Enum, IntEnum, StrEnum, auto(), iteration, comparison, and type hints.
python slots vs dict: Attribute Storage Compared
python slots vs dict: Understand how Python stores object attributes in a dict versus __slots__, and learn when to use each for memory and performance.
Python Slots Memory Optimization: Reduce Instance Memory
Learn how Python's `__slots__` reduces per-instance memory, when to use it, and the tradeoffs with inheritance, dynamic attributes, and weak references.
Python Slots: Save Memory and Speed Up Attribute Access
Learn how Python's __slots__ removes the per-instance __dict__, when inheritance silently reintroduces it, and when slots are a good design choice.
Python Property Validation: Using @property Setters
See how @property setters are used for Python property validation, raise useful errors, and compare this approach with dataclasses and descriptors.