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 Get Line Count of a File
Python String isupper()
Python Program to Find Armstrong Number in an Interval
Python Data Structures and Algorithms - Benjamin Baka
Python String isdigit()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Inheritance
Python String find()
Python Program to Create a Long Multiline String
Python Package
Python Type Conversion and Type Casting
Python Get Current time
Python List Comprehension
Python String splitlines()
Python Program to Measure the Elapsed Time in Python
Python Program to Extract Extension From the File Name
Python while Loop
Python String title()
Python Program to Get the Full Path of the Current Working Directory
Python Program to Display Calendar
Python enumerate()
Python List index()
Python Program to Check the File Size
Python vars()
Deep Learning with Python - Francois Cholletf
Python Program to Count the Number of Occurrence of a Character in String
Python List append()
Python Set issuperset()
Python hex()
Deep Learning with Python - Francois Chollet
Python Set intersection()
Python String rsplit()