Last active
January 30, 2016 14:49
-
-
Save klauer/e6275ccd0ae68b4e20c6 to your computer and use it in GitHub Desktop.
string enum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StrEnum.doc_a | |
True | |
StrEnum.doc_a = A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enum | |
class StrEnum(str, enum.Enum): | |
doc_a = 'A' | |
doc_b = 'B' | |
doc_c = 'C' | |
a = StrEnum('A') | |
print(a) | |
print(a == 'A') | |
print(str(a), '=', a.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment