Pythonの列挙型(Enum)の個数、最大値、最小値の取得の仕方を備忘録として以下に示す。
enum.py
from enum import Enum, unique
@unique
class Position(Enum):
SQUARE = 0
SHORT = 1
LONG = 2
@unique
class Action(Enum):
WAIT = 0
SHORT = 1
LONG = 2
LIQUIDATE = 3
print(len(Action)) # 個数 4
print(max([e.value for e in Position])) # 最大値 2
print(min([e.value for e in Position])) # 最小値 0