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 ascii()
Java Program to Implement the Program Used in grep/egrep/fgrep
Python Iterators
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Set isdisjoint()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Find Numbers Divisible by Another Number
Python Dictionary items()
Python Program to Check Whether a String is Palindrome or Not
Python Program to Find Factorial of Number Using Recursion
Python strptime()
Python Input, Output and Import
Python isinstance()
Python String replace()
Python Dictionary copy()
Python globals()
Python RegEx
Python Program to Return Multiple Values From a Function
Python Program to Count the Occurrence of an Item in a List
Python Set discard()
Python Operators
Python Function Arguments
Python Program to Sort a Dictionary by Value
Python Program to Check If a String Is a Number (Float)
Python Namespace and Scope
Python Program to Multiply Two Matrices
Python Program to Find the Factorial of a Number
Python String isidentifier()
Python sleep()
Python if...else Statement
Python Inheritance
Python String rpartition()