Skip to content

Archive

Data Modeling

1 articles
Python 04 Sep 2026 11 min read

Model Combinable Options in Python with enum.Flag and IntFlag

Some values represent one choice from a fixed set. A log level might be INFO, WARNING, or ERROR. Python’s Enum is a natural fit because one value should identify one member. Other values represent a combination of independent options. A file operation may allow reading and writing. A protocol field may enable compression and encryption. A component may expose several capabilities at the same time. Representing those combinations as ordinary booleans works at first: