Newbie Formatting Question

. soyyo at NOSPAMterra.es
Mon Mar 22 11:33:34 EST 2004


Hi everybody,

I'm new to programming and new to Python.
I'm going through "How to Think Like a Computer Scientist", and 
am in chapter 11. (aside: what do you think of the book? any 
recommendations for other books?)

I have a question about an example of formatting in the book 
(page 120). There is a line that says:

print "%-20x %12.02f" % (student, wages[student])

I understand what's going on, and the example works fine.
I just don't understand what the 0 is doing in the %12.02f format 
specification. I thought it might be to force padding zeroes, but 
I get the same result with or without the 0. Also, %12.0002f 
gives the same result. Was this a typo, or is there something 
that I'm not understanding? 

Thanks in advance for your help.

Ray



More information about the Python-list mailing list