[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Roundup Robot
Change by Roundup Robot : -- keywords: +patch pull_requests: +14358 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14545 ___ Python tracker ___

[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Ethan Furman
Change by Ethan Furman : -- assignee: -> ethan.furman nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Eric V. Smith
Eric V. Smith added the comment: Note that this isn't really related to f-strings, except that they use the __format__ protocol, as does str.__format__. >>> format(myIntEnum.x) '1' -- nosy: +eric.smith ___ Python tracker

[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Jason Curtis
Jason Curtis added the comment: related cPython code: https://github.com/python/cpython/blob/19a1e1eb86115db66c1faae5927f87e3a12692fc/Lib/enum.py#L626 If we're in a mixed-in class but the class has overridden __str__(), we should probably use str(self) instead of self._value_. --

[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Jason Curtis
Jason Curtis added the comment: I mistyped - __str__ can be overridden effectively, but __format__ has to be overridden instead or overridden also to get the desired f-string behavior. -- ___ Python tracker

[issue37479] IntEnum f-string behavior can't be overridden

2019-07-01 Thread Jason Curtis
New submission from Jason Curtis : Combining int and Enum, as with enum.IntEnum results in a class where __str__ cannot be effectively overridden. For example: from enum import IntEnum class myIntEnum(IntEnum): x = 1 def __str__(self): return 'AAAa'