On 9/21/07, cyril giraudon <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I 'd like to know if a std::setw() equivalent function exists in
> python ?
>
> i thought of something like :
>
> a = 16
> "%ai" % 12
>
> But it is not correct.
>
> Any Idea ?

("%i" % 12).rjust(a)

Or, more ugly:

"%%%di" % a % 12

The first % (after quotes) builds this string: "%16i".
Then the second % operation converts that string to '              12'

See also: http://docs.python.org/tut/node9.html
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to