method to intercept string formatting % operations

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Feb 5 17:19:31 EST 2010


On Fri, 05 Feb 2010 16:49:00 +0100, Jean-Michel Pichavant wrote:

> Anyway why would you want to use the tuple form ? it's beaten in every
> aspect by the dictionary form.

Except convenience, efficiency and readability.

"%s %s" % (1, 2)

versus

"%(a)s %(b)s" % {'a': 1, 'b': 2}


I'm all in favour of the second form when you need it. But you certainly 
don't need it all time.



-- 
Steven



More information about the Python-list mailing list