Skip to content

Instantly share code, notes, and snippets.

@tempKDW
Created October 18, 2022 01:17
Show Gist options
  • Save tempKDW/0b64c4d1a796ef2255492645deb7ef27 to your computer and use it in GitHub Desktop.
Save tempKDW/0b64c4d1a796ef2255492645deb7ef27 to your computer and use it in GitHub Desktop.
enum 에서 기본 제공하는 name 과 다른 rule 이 필요할때
class RoleValue(IntEnum):
CEO = 0
CO_CEO = 1
@property
def name(self):
return self._name_.lower().replace("_", "-")
>> RoleValue.CO_CEO.name
'co-ceo'
>> RoleValue.CO_CEO.value
1
>> RoleValue.CO_CEO == 1
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment