Thanks for all the replies: I think I see now - % is a binary operator whose precedence rules are shared with the modulo operator regardless of the nature of its arguments, for language consistency. I understand the arguments behind the format method, but hope that the slightly idiosyncratic print( ..% ..) remains, as the vaguely pictorial "printf" format string is clearer for a long line with several arguments. I will use the "implicit string concatenation" to solve my problem but it is a little odd that an "invisible" operator is stronger than a visible one. (+).
On Mar 16, 5:00 pm, bdb112 <boyd.blackw...@gmail.com> wrote: > # is 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? > > First output > ... print(" %d " + " %d, buckle my shoe" % (1,2)) > > Second output > TypeError: not all arguments converted during string formatting > > Version Info: > Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11) > [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 > > also > > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit > (Intel)] on win32 -- http://mail.python.org/mailman/listinfo/python-list