logo-MindMajix
PostPythonPython
d
divija reddy

Posted on 24th July 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?

1 answers
Answers
P
James ROBERT

Posted on 24th July 2024| views

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
Name
Course *
Email *
Phone Number