Carroll, Barry wrote:
>> -----Original Message-----
>> Date: Mon, 19 Mar 2007 11:53:06 -0400
>> From: Kent Johnson <[EMAIL PROTECTED]>

>> Most string formatting conversions allow you to specify a width
>> directly. For example,
>> In [61]: value = 3.45678
>> In [63]: "%10.3f" % value
>> Out[63]: '     3.457'
>>
>> Kent
>>
> What if one wished to align the values in each column at the decimal
> point?  Is there a simple means to do this in Python, or would one need
> to write a new function?

If you specify the number of digits after the decimal point, that number 
of digits will always be given, so columns will line up:
In [86]: '%10.3f' % 1.2
Out[86]: '     1.200'
In [87]: '%10.3f' % 1.23456
Out[87]: '     1.235'

If you want something fancier I think you will have to do it yourself.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to