Python : All About Enumeration Object
from enum import IntEnum, Enum, unique import sys sys.stdout = open(__name__, 'w') class CountryCode1(Enum): Nepal = 977 India = 91 Pakistan = 92 Bangaladesh = 90 Bhutan = 93 Bhutan = 90 class CountryCode2(IntEnum): Nepal = 977 India = 91 Pakistan = 92 Bangaladesh = 90 Bhutan = 93 Bhutan = 90 def test_countryCode_1(): for i in CountryCode1: print ( "With enum Inherited from Enum => Country : {}, Code : {}" .format(i.name, i.value)) def test_countryCode_2(): try : for i in sorted (CountryCode1): print ( "With enum Inherited from Enum & Trying to Sort Enum Object => Country : {}, Code : {}" .format(i.name, i.value)) except Exception as e: print ( "With enum Inherited from Enum & Trying to Sort Enum Object: {}" .format(e)) de