Okay, let me take a shot at this.

I actually like the status quo for regular enums, when repr() shows the
type, name and value, and str() shows "classname.flagname", so I'd stick to
that for converted flags. Even though this violates the rule of thumb that
repr() should look like a valid expression -- perhaps a stronger rule of
thumb is that repr() should show more than str(). Showing just (the str of)
the value seems unkind, since e.g. showing '4' makes me think it's just an
int. (Then again I can see that for *converted* flags that's not
unreasonable.)

But yeah, backwards compatibility. However, I don't think we got any
complaints about the `re` flags, did we?

On Fri, Sep 18, 2020 at 2:53 PM Ethan Furman <et...@stoneleaf.us> wrote:

> 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 -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/CHQW6THTDYNPPFWQ2KDDTUYSAJDCZFNP/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZFM22AQU2B5P7DQR2N5YL7OVFKZON7B6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to