Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get type of enum variable python

# Python code to demonstrate enumerations
 
# importing enum for enumerations
import enum
 
# creating enumerations using class
class Animal(enum.Enum):
    dog = auto()
    cat = auto()
    lion = auto()
 
# printing enum member as string
print ("The string representation of enum member is : ",end="")
print (Animal.dog)
 
# printing enum member as repr
print ("The repr representation of enum member is : ",end="")
print (repr(Animal.dog))
 
# printing the type of enum member using type()
print ("The type of enum member is : ",end ="")
print (type(Animal.dog))
 
# printing name of enum member using "name" keyword
print ("The name of enum member is : ",end ="")
print (Animal.dog.name)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #type #enum #variable #python
ADD COMMENT
Topic
Name
7+1 =