print with variable justification (with *)

tom tom at t0mb.net
Sat Nov 18 16:07:58 EST 2006


Why Tea wrote:
> print format % values
> An optional minimum width of the conversion, specified using one or
> more digits or an asterisk (*), which means that the width is taken
> from the next item in values
>
> That's from one of O'reilly's books. But there is no example and I
> couldn't get it to work by trials and errors. Does anyone have a
> working example?
>
> /Why Tea
>
>   
value = 3.141592654
print "%1.3f" % value


there you go :)   look at printf in c for general ideas about the format 
specifiers



More information about the Python-list mailing list