Can string format operator help me?

Srihari Vijayaraghavan harisri at bigpond.com
Fri May 10 02:24:25 EDT 2002


Hello,

Please consider the following example:
l = 0
while l < 1000000:
    print "%s" % l
    l = l + 10000

It prints like:
0
10000
..
100000
..

What I want to achieve is something like this:
     0
 10000
..
100000
..

I guess 'Format Operator Auxiliary Directives' (thanks to Core Python
Programming book for the term) * symbol needs to be used in this case.
But I don't know how. I may be wrong though.

I want to be able to do this using string format operator because I am
using tuples/dictionaries as the values.

I understand the Python Library Reference (section 2.2.6.2) gives a
great deal of explanation on this, still I beleive it isn't simple
enough for me :-). I will be thankful if someone can explain me with a
simple example or provide me a pointer to a document on the net.

Thanks for your time.
Hari,
harisri at bigpond.com



More information about the Python-list mailing list