Using enum in python

pip install enum34
from enum import Enum
Animal = enum('Animal', 'ant bee cat dog')

or equivalently:

class Animals(Enum):
    ant = 1
    bee = 2
    cat = 3
    dog = 4

Source: http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python

https://docs.python.org/3/library/enum.html

Comments

Comments powered by Disqus