Enumeration module. In C, enums allow you to declare a bunch of constants with unique values, without necessarily specifying the actual values (except in cases where you need to). Python has an accepted idiom that’s fine for very small numbers of constants (A, B, C, D = range(4)) but it doesn’t scale well to large numbers, and it doesn’t allow you to specify values for some constants while leaving others unspecified. This approach does those things, while verifying that all values (specified and unspecified) are unique. Enum values then are attributes of an Enumeration class (Volkswagen.BEETLE, Volkswagen.PASSAT, etc.).


class Enumeration(name, enumList, flaggable=False, no_doc=False)[source]

Enumeration class intended to provide the ‘enum’ feature present in many programming languages.

The elements of the enumeration can be accessed in an “object member way” or as elements of a dictionary.


from taurus.core.util.enumeration import Enumeration

Volkswagen = Enumeration("Volkswagen",
     ("THING", 400),
     ("CABRIO", 700),

In the command line:

>>> my_car = Volkswagen.BEETLE
>>> homer_car = Volkswagen.PASSAT

>>> print(Volkswagen.BEETLE)

>>> print(Volkswagen['BEETLE'])


(more info)

class EnumException[source]

Exception thrown by Enumeration when trying to declare an invalid enumeration.

(more info)