In this example, you will learn to represent enum.
To understand this example, you should have the knowledge of the following Python programming topics:
Using enum module
from enum import Enum
class Day(Enum):
MONDAY = 1
TUESDAY = 2
WEDNESDAY = 3
# print the enum member
print(Day.MONDAY)
# get the name of the enum member
print(Day.MONDAY.name)
# get the value of the enum member
print(Day.MONDAY.value)
Output
Day.MONDAY MONDAY 1
Here, we have class Day with the object Enum as its argument. name and value are the attributes of Enum which give the name and value of the member MONDAY respectively.
You can refer to the official documentation of enum for more information.
Related posts:
Python format()
Python String isnumeric()
Python Program to Check the File Size
Python str()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Differentiate Between del, remove, and pop on a List
Python list()
Python sorted()
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python Program Read a File Line by Line Into a List
Python object()
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python Program to Check Prime Number
Python Program to Print all Prime Numbers in an Interval
Python String isdecimal()
Python String rsplit()
Python reversed()
Python Decorators
Python Program to Find Sum of Natural Numbers Using Recursion
Python Dictionary pop()
Python Modules
Python String title()
Python hasattr()
Python Function Arguments
Python String swapcase()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Check Armstrong Number
Java Program to Implement the Program Used in grep/egrep/fgrep
Python Iterators
Python Machine Learning - Sebastian Raschka
Python __import__()
Python Program to Generate a Random Number