Hi guys i need help with one thing in Python...
I've got something like

number=001 
example = "picture%d" % number 
print example ---> But it prints picture1 not picture 001....

and i need it as integer not as string because i want to use

--->

number=number + 2 for example...

Thank You guys, sorry for my English, and I hope that you understood

Gribouillis want to stop counter wrap arround to stop program destroying files. Rename = move in Linux systems. Good thinking.

Comments
Thanks for your support !

Gribouillis want to stop counter wrap arround to stop program destroying files. Rename = move in Linux systems. Good thinking.

I read a good rule: assert the most obvious hypotheses about your data :)

Maybe the reason rwas not like I said as formatting normally expands if number does not fit. Still it is easy to optimize out assert statements because they make your dear program slower. Premature optimization is not without reason sin in Python world.

Maybe the reason rwas not like I said as formatting normally expands if number does not fit. Still it is easy to optimize out assert statements because they make your dear program slower. Premature optimization is not without reason sin in Python world.

My idea is that if the OP wanted larger numbers, he would have written picture0001, so there was an implicit assumption which deserved to be checked.

Edited 5 Years Ago by Gribouillis: n/a

This question has already been answered. Start a new discussion instead.