1. Enumerations can be displayed as string or repr .
2. Enumerations can be type checked using type () .
3. The keyword “ name ” is used to display the name of an enumeration member.
The string representation of enum member is: Animal.dog The repr representation of enum member is: & lt; Animal.dog: 1 & gt; The type of enum member is: & lt; enum `Animal` & gt; The name of enum member is: dog
4. Enumerations are repeatable . They can be repeated using loops
All the enum values are: Animal.dog Animal.cat Animal.lion Enum is hashed
Access to modes: There are two ways to access Enum elements
1. By value : — This method is passed the value of an enumeration member.
2. By name : — This method passes the name of an enumeration member.
A single value or name can also be retrieved using the keyword " name " or " value ". p>
Comparison: Enumerations support two types of comparisons
1. Identity : — They are checked using the keywords " is " and " not ".
2. Equality : — Comparisons for equality of types " == " and "! = ".
The enum member associated with value 2 is: Animal.cat The enum member associated with name lion is: Animal.lion The value associated with dog is: 1 The name associated with dog is: dog Dog and cat are different animals Lions and cat are different
This article is courtesy of Manjit Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.