This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients Mariatta, docs@python, eric.smith, martin.panter
Date 2017-09-18.00:14:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505693664.79.0.92292632931.issue31487@psf.upfronthosting.co.za>
In-reply-to
Content
>>> f"{number:#0x}"  # using integer format specifier

It’s not clear what your purpose was adding the above line, but the zero flag (0) does nothing because there is no “width” field. I think it could be misleading, because it is actually the “#x” codes that generate the “0x” prefix.

If you want to illustrate a minimum width, I suggest something like

>>> f"{number:#06x}"
'0x0400'

or (if the number is never negative)

>>> f"0x{number:04X}"
'0x0400'

Or if you don’t care about the width:

>>> f"{number:#x}"
'0x400'
History
Date User Action Args
2017-09-18 00:14:24martin.pantersetrecipients: + martin.panter, eric.smith, docs@python, Mariatta
2017-09-18 00:14:24martin.pantersetmessageid: <1505693664.79.0.92292632931.issue31487@psf.upfronthosting.co.za>
2017-09-18 00:14:24martin.panterlinkissue31487 messages
2017-09-18 00:14:23martin.pantercreate