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 Namespace and Scope
Python Operators
Python Program to Make a Simple Calculator
Python Tuple index()
Python Program to Add Two Matrices
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python Modules
Python issubclass()
Python Program to Compute all the Permutation of the String
Python Program to Merge Mails
Python hex()
Python String isprintable()
Python reversed()
Python String ljust()
Python min()
Python String rsplit()
Python Program to Count the Number of Occurrence of a Character in String
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
How to Get Started With Python?
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python all()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python @property decorator
Python Set symmetric_difference_update()
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Variables, Constants and Literals
Java Program to Implement the Program Used in grep/egrep/fgrep
Python datetime
Python Function Arguments
Python Program to Find Sum of Natural Numbers Using Recursion
Python classmethod()
Python String istitle()