Re: Dynamic Zero Padding.

2011-06-08 Thread Friedrich Clausen
On Wed, Jun 8, 2011 at 4:56 AM, Terry Reedy wrote: > On 6/7/2011 7:05 PM, John Posner wrote: > >> You might want to try "new style" string formatting [1], which I think >> is better than the "old style" in this particular case: >> >>     >>> "Testing {0:0{1}d}".format(42, 4) >>    'Testing 0042' >

Dynamic Zero Padding.

2011-06-07 Thread Friedrich Clausen
Hello All, I want to print some integers in a zero padded fashion, eg. : >>> print("Testing %04i" % 1) Testing 0001 but the padding needs to be dynamic eg. sometimes %05i, %02i or some other padding amount. But I can't insert a variable into the format specification to achieve the desirable padd