print()

Dave Angel davea at ieee.org
Mon Oct 19 04:10:20 EDT 2009


Gabriel Genellina wrote:
> <snip>
>
> but the new str.format() originally suggested by Dave Angel is better:
>
> s = "{0:03.02f}% done".format(100.0-100.0*(size/tot))
>
> (BTW, why 03.02f? The output will always have at least 4 chars, so 03 
> doesn't mean anything... Maybe you want {0:06.2f} (three places before 
> the decimal point, two after it, filled with 0's on the left)?)
>
I deliberately gave an example where every specifier was a different 
digit, so I could easily describe what each part did.  It was intended 
to be understood, not copied.

DaveA



More information about the Python-list mailing list