[issue26506] hex() documentation: mention "%x" % int

Eric V. Smith report at bugs.python.org
Mon Mar 7 13:58:59 EST 2016


Eric V. Smith added the comment:

For 3.5 and 2.7, I'd suggest:
format(value, 'x')
or:
format(value, 'X')

Although you might disagree because of the verbosity. But at least you're not parsing a string at runtime. 

And for 3.6 with PEP-498:
f'{value:x}'

There are of course options for padding and adding the '0x', as well.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26506>
_______________________________________


More information about the Python-bugs-list mailing list