[Python-Dev] Enum and the Standard Library

2020年9月18日 14:49:57 -0700

As you may have noticed, Enums are starting to pop up all over the stdlib [1]. To facilitate transforming existing module constants to IntEnums there is `IntEnum._convert_`. In Issue36548 [2] Serhiy modified the __repr__ of RegexFlag:
 >>> import re
 >>> re.I
 re.IGNORECASE
I think for converted constants that that looks nice. For anyone that wants the actual value, it is of course available as the `.value` attribute:
 >>> re.I.value
 2
I'm looking for arguments relating to:
- should _convert_ make the default __repr__ be module_name.member_name?
- should _convert_ make the default __str__ be the same, or be the
 numeric value?
Thank you for your time!
--
~Ethan~
[1] I'm working on making their creation faster. If anyone wanted to convert EnumMeta to C I would be grateful.
[2] https://bugs.python.org/issue36548
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/CHQW6THTDYNPPFWQ2KDDTUYSAJDCZFNP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to