Skip to main content

3 posts tagged with "enum"

enum tag description

View All Tags

Python enum framework

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Python enum.Enum Advanced Practices for Expert Programmers

For veteran Python engineers, the enum.Enum class is more than just a container for constants; it is a powerful framework for metaprogramming, runtime validation, and object identity. These advanced techniques leverage Python's dunder methods (__new__, _missing_, __format__) and the underlying metaclass to inject behavior and data in highly customized ways, solving obscure but critical architectural problems.

Python Enum Integration with Typing

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

The combination of the standard enum.Enum class and the typing module is a powerful best practice in modern Python. By using an Enum class as a type hint, you signal to static type checkers (like MyPy, Pyright) and fellow developers that only specific, named constants are valid inputs or outputs, enforcing both type safety and value safety.