Beyond constants: Mastering Python enums
summary
Built a Python port of HDate for Home Assistant that models Hebrew months as enums with methods to advance dates and lambdas for variable month lengths, showing how enums hold metadata and behave like classes. A separate Intel tool generates enums from a runtime config dictionary for dynamic enum generation, which gives automatic validation and better type hints. Practical failures: attaching mutable attributes (e.g., a language field) exposes the enum singleton bug so state leaks across uses, and tests become order-dependent; enums work but avoid per-user or runtime-changing state.
AI-written summary · about
