Death to tuples!

Rikard Bosnjakovic bos at REMOVETHIShack.org
Tue Nov 29 01:50:26 EST 2005


Steven Bethard wrote:

> [1]http://www.python.org/dev/summary/2005-09-01_2005-09-15.html#string-formatting-in-python-3-0 

Reading this link, I find this:

"Currently, using % for string formatting has a number of inconvenient 
consequences:

     * precedence issues: "a%sa" % "b"*4 produces 'abaabaabaaba', not 
'abbbba' " [...]


Testing it locally:

 >>> "a%sa" % "b"*4
'abaabaabaaba'

But "b"*4 is not a tuple, as the formatting arguments are supposed to be, 
so why blame its erronious behaviour?

Works fine this way:

 >>> "a%sa" % ("b"*4,)
'abbbba'

So I really do not see the problem. For my own format-strings, I always 
add a final comma to make sure it's a tuple I'm using.

Just my $0.02.


-- 
Sincerely,                      |                http://bos.hack.org/cv/
Rikard Bosnjakovic              |         Code chef - will cook for food
------------------------------------------------------------------------



More information about the Python-list mailing list