Beyond constants: Mastering Python enums

Tsvi Mostovicz Tsvi Mostovicz
Language: Hebrew
The presentation was given on 2025.09.09 at PyCon Israel 2025 - Conference.

Explore advanced enum usage in Python: define methods, attach metadata, and create enums dynamically. Learn the benefits and pitfalls of the enum singleton to write more expressive and maintainable code.

While working on the open-source hdate library (which I maintain) and on internal tools at Intel, I came across some lesser-known but powerful uses of Python enums. From attaching extra data and methods to make code more expressive, to dynamically generating enums from configuration files, these patterns can add clarity to your code if used with care. In this talk, I’ll share these techniques, their advantages, and the subtle pitfalls to watch out for when using a singleton data structure.