0

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

4
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by Gribouillis
Featured Replies
  • 1

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

1

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

Comments
Thanks for your support !
0

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 :)

0

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.

0

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 by Gribouillis: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.