Enumerations comes under User defined data types
The Python documentation describes an enum like this: An enumeration is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over
>>> from enum import Enum
>>> class Person(Enum):
raj=1
sita=2
laxman=3
>>> print(Person.raj)
Person.raj
>>>
Properties of enum:
1. Enums can be displayed as string or repr.
2. Enums can be checked for their types using type().
3. “name” keyword is used to display the name of the enum member.
You may like the following programs:
The Python documentation describes an enum like this: An enumeration is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over
>>> from enum import Enum
>>> class Person(Enum):
raj=1
sita=2
laxman=3
>>> print(Person.raj)
Person.raj
>>>
Properties of enum:
1. Enums can be displayed as string or repr.
2. Enums can be checked for their types using type().
3. “name” keyword is used to display the name of the enum member.
You may like the following programs:
No comments:
Post a Comment