New Python 3.0 string formatting - really necessary?

MRAB google at mrabarnett.plus.com
Sat Dec 20 18:47:53 EST 2008


walterbyrd wrote:
> On Dec 19, 12:43 pm, excord80 <excor... at gmail.com> wrote:
> 
>> Also, I like having only *one* special symbol (`%') to worry
>> about in my strings instead of two (`{' and `}').
>>
> 
> Actually the new way has, at least three special symbols: ( '{', '}' ,
> '.') as well as the method name "format" so
> 
> "%s=%s" % (k, v) for k, v in params.items()
> 
> becomes:
> 
> "{0}={1}".format((k, v) for k, v in params.items())
> 
> or something like that.
> 
"{0}={1}".format(k, v) for k, v in params.items()

or:

"{0}={1}".format(*i) for i in params.items()



More information about the Python-list mailing list