print with variable justification (with *)
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sat Nov 18 16:07:00 EST 2006
In <1163883589.401180.271190 at m73g2000cwd.googlegroups.com>, 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?
In [50]: '%*s' % (5, 'spam')
Out[50]: ' spam'
In [51]: '%*s' % (10, 'spam')
Out[51]: ' spam'
In [52]: '%*s' % (15, 'spam')
Out[52]: ' spam'
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list