Using enum in python

Install enum module prior to python 3.4

pip install enum34

Example:

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