On Fri, 2 Jun 2017 10:17:05 -0700 (PDT), sean.diza...@gmail.com wrote: [snip] >>>> print "foo %s" % 1-2 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: unsupported operand type(s) for -: 'str' and 'int'
Others have already pointed out that you're assuming the wrong precedence: Say "foo %s" % (1-2) not ("foo %s" % 1) - 2 . Personally I prefer a less compact but more explicit alternative: "foo {}".format(1-2) -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list