A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-August/127988.html below:

[Python-Dev] format, int, and IntEnum

[Python-Dev] format, int, and IntEnumEric V. Smith eric at trueblade.com
Thu Aug 15 19:44:15 CEST 2013
On 08/15/2013 11:21 AM, Ethan Furman wrote:
> Given that the !r and !s format codes can be used to get the repr and
> str of an IntEnum, would it be acceptable to have IntEnum's __format__
> simply pass through to int's __format__?  And likewise with all mix-in
> classes?

That helps with str.format(), but not with built-in format(). There,
you'd have to explicitly call str() or repr():


>>> '{:10}'.format(True)
'         1'
>>> format(True, '10')
'         1'

>>> '{!s:10}'.format(True)
'True      '
>>> format(str(True), '10')
'True      '

Eric.




More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4