range with variable leading zeros

yhvh yhvh2000 at googlemail.com
Thu May 8 23:42:59 EDT 2008


I want to generate a range with variable leading zeros


x = [0010, 0210]
padding = len(x[1])

for j in range(x[0], x[1]):
    print (url).join('%0(pad)d(jj)'+'.jpg') %{'pad':padding, 'jj':j}


This is syntactically incorrect, you can't insert a variable into the
string format options. Any ideas?



More information about the Python-list mailing list