>>I think I am more impressed that you understand than what he wrote :)
>
>I understood it when I read it. Don't ask me to repeat it tomorrow.
>I was fortunate to have as one of my programming mentors a brilliant mathematician who forced this English major to learn to appreciate the beauty of mathematics.
>So, while I'll never be able to do what Lutz does, I can follow it, appreciate its elegance and apply it.
In some cases I also used log10() to count the width of the integer part of a number, as it's rather straightforward and independent of any textual representation of the number. Any number above 1 has int(log10(number))+1 digits to the left of the decimal point. Or, to put it straight, log10(number) gives you the position of the leftmost non-zero digit of the number, counting the ones as the zeroeth, tens as 1st etc, 0.x as -1st, 0.0x as -2nd etc.