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 Dictionary values()
Python Program to Display Fibonacci Sequence Using Recursion
Python Program to Convert Celsius To Fahrenheit
Python Program to Get the File Name From the File Path
Python Program to Merge Mails
Python Program to Get Line Count of a File
Python List
Python Program to Create Pyramid Patterns
Python Machine Learning Eqution Reference - Sebastian Raschka
Python Program to Count the Number of Digits Present In a Number
Python Program to Print the Fibonacci sequence
Python String center()
Python String isprintable()
Python Program to Iterate Over Dictionaries Using for Loop
Python Set issuperset()
Python Program to Append to a File
Python Program to Convert Decimal to Binary Using Recursion
Python map()
Python Tuple index()
Python String index()
Python Anonymous / Lambda Function
Python Sets
Python object()
Python frozenset()
Python List sort()
Python hash()
Python Shallow Copy and Deep Copy
Python dict()
Python Set symmetric_difference_update()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python locals()