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 Find All File with .txt Extension Present Inside a Directory
Python memoryview()
Python Set symmetric_difference_update()
Python Program to Convert String to Datetime
Python String rstrip()
Python any()
Python Program to Differentiate Between type() and isinstance()
Python object()
Python String format_map()
Python Program to Print Output Without a Newline
Python Program to Convert Decimal to Binary Using Recursion
Python Program to Check If a List is Empty
Python Program to Find Armstrong Number in an Interval
Python Dictionary pop()
Python exec()
Python Program to Display Powers of 2 Using Anonymous Function
Python Set difference()
Python Dictionary items()
Python Set symmetric_difference()
Python Program to Count the Occurrence of an Item in a List
Python Recursion
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Program to Copy a File
Python Program to Transpose a Matrix
Python Program to Get the Full Path of the Current Working Directory
Python String endswith()
Python String translate()
Python List clear()
Python chr()
Python Dictionary popitem()
Python Program to Add Two Numbers
Deep Learning with Python - Francois Chollet