aenum --- support for advanced enumerations
and namedtuples
An enumeration is a set of symbolic names (members) bound to unique, constant values. Within an
enumeration, the members can be compared by identity, and the enumeration itself can be iterated over.
A NamedTuple is a class-based, fixed-length tuple with a name for each possible position accessible
using attribute-access notation.
Module Contents
This module defines five enumeration classes that can be used to define unique sets of names and
values, one Enum class decorator, and one named tuple class
Enum
Base class for creating enumerated constants. See section Enum Functional API for an alternate
construction syntax.
IntEnum
Base class for creating enumerated constants that are also subclasses of int.
AutoNumberEnum
Derived class that automatically assigns an int value to each member.
OrderedEnum
Derived class that adds <, <=, >=, and > methods to an Enum.
UniqueEnum
Derived class that ensures only one name is bound to any one value.
unique
Enum class decorator that ensures only one name is bound to any one value.
NamedTuple
Base class for creating NamedTuples, either by subclassing or via it's functional API.
Note
the UniqueEnum class and the unique decorator both do the same thing, you do not need to
use both of them at the same time.
Creating an Enum
Enumerations are created using the class syntax, which makes them easy to read and write. An
alternative creation method is described in Enum Functional API. To define an enumeration, subclass
Enum as follows: