[Tutor] printing statement

bob bgailer at alum.rpi.edu
Fri Nov 4 16:56:18 CET 2005


At 10:02 PM 11/3/2005, Johan Geldenhuys wrote:
>Found it. This is what I was looking for:
>"""
> >>> print ('file'+'dir'.center(20))+('\n'+'='*15)
>file        dir
>===============
> >>>
>"""

I am glad you found what you wanted. I'm sad that you did not tell us more 
precisely what you wanted, as we could have steered you in that direction.

center() puts spaces to the right of dir. It that part of what you wanted, 
or just a side effect.?

I'd find less () easier to read:
print 'file'+'dir'.center(20)+'\n'+'='*15

and 2 print statements even better:
print 'file'+'dir'.center(20)
print '*15

>It's actually a string operator 'center(width)' that I was looking for.
>
>I saw the '%', but that is what I wanted to use.

Do you also appreciate the power of %? I hope you learn to use it also.
[snip] 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051104/4452bb08/attachment.htm


More information about the Tutor mailing list