["python","enums"]
What's the common practice for enums in Python?

How can I implement an enumeration type (spelled enum in some languages) in Python? What is the common practice to get this functionality?
class Materials: Shaded, Shiny, Transparent, Matte = range(4) >>> print Materials.Matte 3 Update: For Python 3.4+: As of Python 3.4+, you can now use Enum (or IntEnum for enums with int values) from the enum module. Use enum.auto to increment the values up automatically: import enum class Materials(enum.IntEnum): Shaded = 1 Shiny = enum.auto() Transparent = 3 Matte = enum.auto() print(Materials.Shiny == 2) # True print(Materials.Matte == 4) # True