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 Tuple count()
Python Program to Count the Number of Each Vowel
Python Program to Create a Countdown Timer
Python Program to Get the File Name From the File Path
Python ascii()
Python time Module
Python oct()
Python dict()
Python Program to Illustrate Different Set Operations
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python Program to Sort a Dictionary by Value
Python Program to Convert Celsius To Fahrenheit
Python Dictionary values()
Python Dictionary popitem()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python Program to Find the Sum of Natural Numbers
Python bytes()
Python object()
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python input()
Python del Statement
Python super()
Python filter()
Python Global Keyword
Python Set clear()
Python List extend()
Python String replace()
Python len()
Python Object Oriented Programming
Python Program to Differentiate Between type() and isinstance()
Python pass statement
Python Variables, Constants and Literals