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

STINNER Victor report at bugs.python.org
Fri Mar 11 03:37:32 EST 2016


STINNER Victor added the comment:

I opened the issue when I read this change:
https://review.openstack.org/#/c/288224/2/neutron/common/utils.py

    rndstr = hex(...)[2:]
    # Whether there is a trailing 'L' is a py2/3 incompatibility
    rndstr = rndstr.rstrip('L')
    return rndstr.zfill(length)

can be simply written

    return "{0:0{1}x}".format(..., length)

It's less readable, but it's more efficient.

----------

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


More information about the docs mailing list