Post

PythonPython

d
divija reddy

Posted on 25th April 2024|43 views

0
votes

What Is The Best Way To Implement Enums In Python?

Can you explain me the best way to implement enums in Python?

Answers
P
James ROBERT

Posted on 25th April 2024

Hey Divija,

You can try the following method:

from enum import Enum

class Class(Enum):

A = 1

B= 2

C = 3

print(repr(Class.a))

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos