Format Strings -- Real vs. Expected Behaviour
Brad Bollenbach
bbollenbach at homenospam.com
Mon Apr 16 20:48:45 EDT 2001
Just curious, from Python 2.0...
This:
print "%s %s" % ("hello", "world")
prints "hello world"
whereas this:
print "%s " + \
"%s" % ("hello", "world")
Results in "TypeError: not all arguments converted".
but this:
print ("%s " + \
"%s") % ("hello", "world")
prints "hello world" as well.
Shouldn't Python be smart enough to know that even without ()'s around the
whole thing, this is all one line (therefore avoiding the current
odd/unexpected IMHO behaviour with the format string)? After all, I'm
telling it this much by using the line continuation character "\" aren't I?
--
Brad Bollenbach,
Python Hacker
More information about the Python-list
mailing list