Error on string formatting

Alex alex at somewhere.round.here
Tue Feb 8 18:20:43 EST 2000


Perhaps it's a matter of operator precedence?  Do you want to do 

>>> '%0.*f' % (3, 4.1)
'4.100'
>>> 

instead?

Alex.

> >>> buf = '%0.*f' % 3, 4.1
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> TypeError: not enough arguments for format string
> 
> The comparable statement in C works fine, and the Essential Reference
> says I can do this kind of asterisk thing.
> 
> Judy Hawkins



More information about the Python-list mailing list