Skip to content

Instantly share code, notes, and snippets.

@headsrooms
Created September 24, 2017 14:07
Show Gist options
  • Save headsrooms/c4101584dc8d6dcf8a6db9e9eb42d7f3 to your computer and use it in GitHub Desktop.
Save headsrooms/c4101584dc8d6dcf8a6db9e9eb42d7f3 to your computer and use it in GitHub Desktop.
Useful to generate choices field (tuple of tuples) from Enum
from enum import Enum
class TupleEnum(Enum):
@classmethod
def tuple(cls):
return tuple(((elem.name, elem.value) for elem in cls))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment