Thanks, i am using this at the moment, just wanted to know if there is something faster - in Python zfill is faster than "0" * 7. I am just asking because i am using this a *lot* of times, so if there is an at least slightly faster alternative ,i should probably consider it. But if "0"*7 is the 'normal' way of doing this, it's OK with me.
It looks like zfill is primarily used for padding numbers, in which
case I'd use sprintf:
sprintf("%07d", 6) or "%07d" % 6
=> "0000006"
Not sure how well it benchmarks - probably better if it maps to the C
sprintf function. But you're just looking for zeros without padding an
existing number? You could always pad out 0 to one less then what you
want, but I guess that would be overcomplicating things even if it was
a little faster.
Thanks, i am using this at the moment, just wanted to know if there is
something faster - in Python zfill is faster than "0" * 7. I am just
asking because i am using this a *lot* of times, so if there is an at
least slightly faster alternative ,i should probably consider it. But if
"0"*7 is the 'normal' way of doing this, it's OK with me.