Created
September 24, 2017 14:07
-
-
Save headsrooms/c4101584dc8d6dcf8a6db9e9eb42d7f3 to your computer and use it in GitHub Desktop.
Useful to generate choices field (tuple of tuples) from Enum
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
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