Query about doing fortran-esque repeat formatting
Mensanator
mensanator at aol.com
Sun Nov 8 11:08:55 EST 2009
On Nov 8, 8:56�am, Rob Briggs <rdbri... at mun.ca> wrote:
> Hello,
>
> Is there a way to do a repeat formatting command like in Fortran? Rather
> that doing this:
>
> print "%s %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f %-5.3f" %
> (parmName[i], tmp[i][1], tmp[i][2], tmp[i][4], �tmp[i][6], �tmp[i][7],
> tmp[i][8], �tmp[i][9])
>
> Something like this:
>
> print "%s 7%-5.3f % (parmName[i], tmp[i][1], tmp[i][2], tmp[i][4],
> tmp[i][6], �tmp[i][7], tmp[i][8], �tmp[i][9])
>
>>> s = '%s ' + ' %-5.4f' * 7
>>> s
'%s %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f %-5.4f'
>>> print s % ('s',1,2,3,4,5,6,7)
s 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000
> regards,
>
> Rob
More information about the Python-list
mailing list