Newbie, homework help, please.

Tim Chase python.list at tim.thechases.com
Sat Apr 21 16:12:31 EDT 2012


On 04/21/12 14:44, Roy Smith wrote:
>> 	***********************
>> 	*                     *
>> 	* First Name and Last *
>> 	* ENGR 109-X          *
>> 	* Fall 2999           *
>> 	* Format Example      *
>> 	*                     *
>> 	***********************
>
> You can take advantage of python's string formatting capabilities (which
> are pretty much the same as C's printf() formatting), and do something
> like:
>
> print  "* %-*s *" % (max_length, data)

Sounds like a lot more work and less flexible than using the 
(underemployed) .ljust() or .center() methods of a string. :-)

   print "* %s *" % data.ljust(42)

-tkc






More information about the Python-list mailing list