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

Ezio Melotti report at bugs.python.org
Mon Mar 21 07:11:35 EDT 2016


Ezio Melotti added the comment:

> Note: Ezio, do you prefer format(value, 'x') for '{:x}'.format(value)?

While formatting a single value the former is better/shorter, but the latter is perhaps more common since you usually have something else in the string too.

The latter can also be used to do something like:
>>> '{num:x} {num:X} {num:#x} {num:#X}'.format(num=255)
'ff FF 0xff 0XFF'

----------

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


More information about the docs mailing list