Skip to content

Instantly share code, notes, and snippets.

@wamsachel
Created August 4, 2015 20:04
Show Gist options
  • Select an option

  • Save wamsachel/92561357ff5f9f75b33a to your computer and use it in GitHub Desktop.

Select an option

Save wamsachel/92561357ff5f9f75b33a to your computer and use it in GitHub Desktop.
Hasty python enum (Enum type included in python versions after 3.4)
#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