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 Program to Trim Whitespace From a String
Java Program to Implement the Program Used in grep/egrep/fgrep
How to get current date and time in Python?
Python Program to Display Calendar
Python RegEx
Python List reverse()
Python String expandtabs()
Python Program to Print Hello world!
Python min()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Dictionary get()
Deep Learning with Python - Francois Chollet
Python Recursion
Python String upper()
Python Program to Delete an Element From a Dictionary
Python Dictionary setdefault()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Get Line Count of a File
Python Strings
Python Program to Swap Two Variables
Python Multiple Inheritance
Python List remove()
Python dir()
Python Program to Parse a String to a Float or Int
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python List copy()
Python while Loop
Python String isdigit()
Python range()
Python Program to Find LCM
Intelligent Projects Using Python - Santanu Pattanayak
Python bytes()