On 11/21/2012 6:21 PM, Joshua Landau wrote:
Since we've decided to derail the conversation...
"{}".format() is a blessing an "" % () should go. "%" has no relevance
to strings, is hard to "get" and has an appalling* syntax. Having two
syntaxes just makes things less obvious, and the right choice rarer.
str.format is also really easy. I don't understand what makes you disagree.
Easy vs easier:
>>> "%s %s %s" % (1, 2, 3)
'1 2 3'
>>> "{} {} {}".format(1, 2, 3)
'1 2 3'
You forgot the cases where % formatting has to be special cased.
>>> "The answer is {}.".format(1)
'The answer is 1.'
>>> "The answer is {}.".format((1,))
'The answer is (1,).'
>>> "The answer is %s" % 1
'The answer is 1'
>>> "The anwser is %s" % (1,)
'The answer is 1'
>>> "The answer is %s" % ((1,),)
'The answer is (1,)'
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list