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 Set symmetric_difference()
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python setattr()
Deep Learning in Python - LazyProgrammer
Python List index()
Python Dictionary copy()
Python String lower()
Python Program to Get the File Name From the File Path
Python Program to Convert Decimal to Binary Using Recursion
Python String isdigit()
Python Program to Count the Number of Each Vowel
Python String format_map()
Python super()
Python Get Current time
Python frozenset()
Python frozenset()
Deep Learning with Python - Francois Cholletf
Python @property decorator
Python list()
Python Program to Check If Two Strings are Anagram
Python delattr()
Python Program to Find Numbers Divisible by Another Number
How to Get Started With Python?
Python time Module
Python abs()
Python Program to Count the Number of Occurrence of a Character in String
Python Program to Get the Full Path of the Current Working Directory
Python List Comprehension
Python vars()
Python Dictionary get()
Python Directory and Files Management
APIs in Node.js vs Python - A Comparison