print - bug or feature - concatenated format strings in a print statement

Scott David Daniels Scott.Daniels at Acm.Org
Mon Mar 16 20:27:08 CET 2009


bdb112 wrote:
> ... the difference between ...
> print(" %d,  %d, buckle my shoe" % (1,2))
> ... and ...
> print(" %d, " + " %d, buckle my shoe" % (1,2))
> # a bug or a feature?

A feature.   a + b % c   is   a + (b % c)
But do note that string constant concatentation is higher priority
than the other operators.
 > print(" %d, "  " %d, buckle my shoe" % (1,2))

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list