[Tutor] Making table

Alan Gauld alan.gauld at btinternet.com
Thu Mar 22 10:21:40 CET 2007

"Kent Johnson" <kent37 at tds.net> wrote in message

>> One final tip is to put the format string in a variable then use 
>> that
>> in printing/writing the output ...
>> This has the advantage that you can build the format string
>> dynamically by examining the data first - eg the maximum
>> length of an entry.

> You don't need to build the format string dynamically to get control 
> of
> the maximum width. A neat trick is that if you use '*' for the 
> format
> width, the width will be read from the parameter list:

Good point, I usually forget that one...

However predefined format strings have other advantages too
- consistency for one thing. You can write output in multiple
places and be sure the format is consistent throughout.

Alan G. 

More information about the Tutor mailing list