Use the IntEnum or loop through it to enum get all values in Python.
Example Get all values from an enum class
from enum import IntEnum class Country(IntEnum): Afghanistan = 93 Albania = 355 Algeria = 213 country_codes = list(map(int, Country)) print(country_codes)
Uusing list comprehension.
from enum import Enum class Color(Enum): RED = 1 BLUE = 2 res = [e.value for e in Color] print(res)
Output: [1, 2]
Do comment if you have any doubts and suggestions on this Python enum topic,
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.