Код: Выделить всё
from enum import Enum
class Label(enum):
RedApple = 1
GreenApple = 2
Код: Выделить всё
fruitname = "redapple"
a = Label[fruitname]
Код: Выделить всё
def __init__(self, key):
super(Label, self).__init__()
pass # do comparison here
Код: Выделить всё
super(Label, self).__init__()
NameError: global name 'Label' is not defined
Подробнее здесь: https://stackoverflow.com/questions/426 ... itive-enum
Мобильная версия