Created
August 4, 2015 20:04
-
-
Save wamsachel/92561357ff5f9f75b33a to your computer and use it in GitHub Desktop.
Hasty python enum (Enum type included in python versions after 3.4)
This file contains hidden or 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
| #Taken from http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python | |
| def enum(**enums): | |
| return type('Enum', (), enums) | |
| Numbers = enum(ONE = 1, TWO = 2, THREE = 'three') | |
| Numbers.ONE | |
| >> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment