On Mon, Jul 11, 2016 at 12:54 PM, Terry Reedy <tjre...@udel.edu> wrote: > In any case, I think it an improvement to say that '0x00123' has a field > width of 7 rather than a 'precision' of 5. > >>>> '{:#07x}'.format(0x123) # specifiy field width > '0x00123' >>>> "%#0.5x" % 0x123 # specify int precision > '0x00123'
It occurs to me now that this does create a challenge if the format is meant to support negative numbers as well: >>> '%#0.5x' % -0x123 '-0x00123' >>> '{:#07x}'.format(-0x123) '-0x0123' -- https://mail.python.org/mailman/listinfo/python-list