Python arrays and sting formatting options

Ivan Reborin ireborin at
Tue Sep 30 02:16:41 CEST 2008

On Mon, 29 Sep 2008 16:08:28 -0700 (PDT), Mensanator
<mensanator at> wrote:

>> 2. I've read the help on the next one but I just find it difficult
>> understanding it.
>> I have;
>> a=2.000001
>> b=123456.789
>> c=1234.0001

Hello Mensanator, thank you for answering in such a short time.

< snip >

>If you actually meant 7, then use %0.6e:

Sorry about that; I have the habit of counting the point as a decimal
place too.
>>>> print '%0.6e' % 2.000001
>>>> print '%0.6e' % 123456.789
>>>> print '%0.6e' % 1234.0001

I understood the above from help, but it's not what's been bugging me.
Mea culpa, I've defined the question in a confusing way, I see that
now. What I've meant to ask was, when I have 3 numbers, how would you
print them with the same format which would apply to them 3 numbers.

for example, I have
print a,b,c

now if I print them with 
print '%12.3f' %a,b,c
the format will apply only to a, and not to b and c. I could of course
print '%12.3f %12.3f ... 3 times
but that is just unpractical.

Is there a way to just do something like this (not normal syntax, just
my wishful thinking):
print 3*'%12.3f' %a,b,c
(meaning - use this format for the next 3 real numbers that come


More information about the Python-list mailing list