Python enum class @Unique














































Python enum class @Unique



One of the python most beautiful python enum is that, the member values of enum class can be maintained unique by employing @unique decorator. If the values of the enum class is unique,.
The code snippet below illustrates the @unique decorator when the member values are unique.
Further, any duplicate value if found member value, the @unique throws error as depicted by the snippet below-
The @unique decorator checks for the duplicity, if found, it raises value error stating <enum 'notunique'>

Comments