TWO ways to do enumerations in MODERN Python 🐍 #shorts #python

preview_player
Показать описание
Enumerations were added in Python 3.4. There are 2 different syntaxes for creating them:
1. Call the Enum() directly
Fruit = Enum('Fruit', 'apple pear grape')

2. Create a class inheriting from Enum
class Animal(Enum):
DOG = 1
CAT = 2
Рекомендации по теме
visit shbcf.ru