Dynamic construction of a print format string

Daniel Dittmar daniel at dittmar.net
Wed Mar 14 15:04:26 EST 2001


If you want to set some format size dynamically, you can use the *
option.

"%*s" % (namelen, data)

Not quite the asnwer to your question, but maybe the solution to your
problem.

Daniel

Bruce Edge wrote:
> 
> I'm using:
> 
>   fmtstr = "%s%s%s" % ( "    %", namelen, "s - %s" )
> 
> to get:
> 
>   "    %19s - %s"
> 
> Is there a better way?
> 
> TIA, Bruce.



More information about the Python-list mailing list