I'd guess it is totally up to the object, since str() calls `__str__` and
format() calls `__format__`. Of course this now begs the question whether
those enums should perhaps change their `__format__` to match their
`__str__`...? But that would not suit your purpose. Then again, how would
one get the pretty IntEnum-specific representation in a format- or
f-string? I guess f"{flag!s}" would work.On Tue, Apr 20, 2021 at 7:59 AM Ethan Furman <[email protected]> wrote: > urllib.urlencode currently uses `str()` on its non-bytes objects before > encoding the result. This causes a > compatibility break when integer module constants are converted to > IntEnum, as `str(IntEnum.MEMBER)` no longer returns > the integer representation; however, `format()` does still return the > integer representation. > > The fix is to add a separate branch to check if the argument is an Enum, > and use the value if so -- but it got me > wondering: in general, are there differences between calling str() vs > calling format() on Python objects? > > -- > ~Ethan~ > _______________________________________________ > 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/24OF6XMFYK4PO2VPY6UFT2S3CBZFNOKB/ > 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 -- [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/VCF3JTEQ53756EZMDXQNEF24PEQWZEZD/ Code of Conduct: http://python.org/psf/codeofconduct/
