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 Wicken
Recipients Wicken
Date 2019-10-31.20:36:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572554160.44.0.882070489525.issue38657@roundup.psfhosted.org>
In-reply-to
Content
When formatting an integer as a hexadecimal value, the '#' alternate form modifier inserts a preceding '0x'. 
If this is used in combination with padding modifiers, the '0x' is counted as part of the overall width, which does not feel like the natural behaviour as extra calculation is required to get the correct post '0x' precision.

Example:

In [7]: f'{num:04x}'
Out[7]: '0800'

In [8]: f'{num:#04x}'
Out[8]: '0x800'

To get the hexadecimal representation padded to 4 digits, you have to account for the preceding 0x:

In [10]: f'{num:#06x}'
Out[10]: '0x0800'
History
Date User Action Args
2019-10-31 20:36:00Wickensetrecipients: + Wicken
2019-10-31 20:36:00Wickensetmessageid: <1572554160.44.0.882070489525.issue38657@roundup.psfhosted.org>
2019-10-31 20:36:00Wickenlinkissue38657 messages
2019-10-31 20:36:00Wickencreate