On Thu, Sep 29, 2011 at 5:47 PM, rantingrick <rantingr...@gmail.com> wrote: > Ah ha! Found the answer! > > py> "{0:010d}".format(1234) > 0000001234 > > py> "{0:0>10}".format(1234) > 0000001234 > > py> "{0:0>10}".format("1234") > 0000001234 > > py> "{0:@>10}".format("1234") > @@@@@@1234 > > I would skip using the "{int}{repeat}d" syntax and just use the string > padding since you won't need to worry about the input data type. I > hate specificity types in string formats. With the old interpolation i > ALWAYS used %s for everything.
Nope, that doesn't work. >>> "{0:0>10}".format("-1234") '00000-1234' The whole point of zfill is that it handles signs correctly. -- http://mail.python.org/mailman/listinfo/python-list