in Education by
Can anyone tell me how I can represent the equivalent of an Enum in Python? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
@Chandini , Enum was added to Python 3.4 and more advanced technques can be used using aenum library.To use aenum ,run $ pip install aenum. Ex- For new versions, from enum import Enum Stationary = Enum('Stationary', 'pen pencil eraser ink') Stationary.pen #returns Stationary['pen'] #returns Stationart.pen.name #returns ‘pen’ For earlier versions: def enum(**enums): return type('Enum', (), enums) Example- >>> Num = enum(ZERO='zero',ONE=1, TWO='two') >>>Num.ZERO 'zero' >>> Num.ONE 1 >>> Num.TWO 'two'

Related questions

0 votes
    Can someone tell me a python -m SimpleHTTPServer equivalent Python 3? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I'm creating my first program on python. The objective is to get an output of trip cost. In the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I am looking to write a pop-up window which asks the user to select a specific option, and if ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I need to find a message the bot has previously posted, then see the reactions on it. I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I have multiple xlsx files with data in it that i want to import to separate dataframes in Python. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I have multiple xlsx files with data in it that i want to import to separate dataframes in Python. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I want to get the values of col1 in 3 different columns with separate headers. Date/Time col1 0 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I have a dataset, say: DateJoined Name Number DateLeft 11/03/2015 Tom 001199 11/03/2019 11/03/ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    When I try to run this pygame code it instantly closes?? The window doesn't close instantly when I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    How can I remove the last character of a string in a newline, In perl I used chomp function what's equivalent to that in Python? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Can someone tell me how to put time delay in the script of Python? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    How to remove an element from a list by index in Python, I tried list.remove method but it search the list and ... How can I do this? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Currently I am working on this code: customer_telno = customer.find('div', 'customer_phone_number') customer_telno = ... this problem? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    How can I convert a str from uppercase, or half uppercase to lowercase? E.x. "Decimeter" to "decimeter" Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    How can I get the number of elements of a list? Ex- items = [] items.append("one") items.append("two") items.append("three") Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
...