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 String encode()
Python __import__()
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python Program to Display the multiplication Table
Python String isdecimal()
Python String splitlines()
Python getattr()
Python Program to Print Colored Text to the Terminal
Python del Statement
Debug a JavaMail Program
Python print()
APIs in Node.js vs Python - A Comparison
Python Type Conversion and Type Casting
Python next()
Python Program to Swap Two Variables
Python Machine Learning Eqution Reference - Sebastian Raschka
Python Dictionary items()
Python eval()
Python Program to Convert Two Lists Into a Dictionary
Python Program to Find Numbers Divisible by Another Number
Python Program to Merge Two Dictionaries
Python str()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python String strip()
Python Objects and Classes
Python abs()
Python String swapcase()
Python Program to Create a Countdown Timer
Python Program to Print Hello world!
Python Recursion
Python List pop()