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 Append to a File
Java Program to Implement the Program Used in grep/egrep/fgrep
Python Program to Shuffle Deck of Cards
Python Operators
Python pass statement
Python Program to Get File Creation and Modification Date
Python Keywords and Identifiers
Python String format()
Python String isupper()
Python String endswith()
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python Functions
Python Program to Print Output Without a Newline
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Program to Check the File Size
Python Closures
Python Program to Check Armstrong Number
Python super()
Python classmethod()
Python String rpartition()
Python Multiple Inheritance
Python List
Python Program to Differentiate Between type() and isinstance()
Python Program to Get the Full Path of the Current Working Directory
Python input()
Python __import__()
Python Program to Check If a List is Empty
Python Matrices and NumPy Arrays
Python Dictionary pop()
Python Machine Learning Second Edition - Sebastian Raschka & Vahid Mirjalili
Python Exception Handling Using try, except and finally statement
Python Program to Iterate Through Two Lists in Parallel