Created
October 18, 2022 01:17
-
-
Save tempKDW/0b64c4d1a796ef2255492645deb7ef27 to your computer and use it in GitHub Desktop.
enum 에서 기본 제공하는 name 과 다른 rule 이 필요할때
This file contains 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
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