Ben Chuanlong Du's Blog

It is never too late to learn.

Enum in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comments

  1. You must assign a value to each enum member.
In [1]:
from enum import Enum
In [3]:
class Color(Enum):
    RED = 0
    GREEN = 1
In [4]:
Color.RED
Out[4]:
<Color.RED: 0>
In [ ]:

Comments