Why do this?

Ivan Voras ivoras at fer.hr
Thu Oct 5 07:16:53 EDT 2006


Duncan Booth wrote:

> print "There are"+number+"ways to skin a"+furryanimal
> 
> or at least something equivalent to it. If I try to make the same mistake 
> with a format string it jumps out to me as wrong:
> 
> "There are%sways to skin a%s" % (number, furryanimal)

Related to this, formatting with sequences is also much more readable 
when there are complex interpunction and quoting characters present, 
like this:

print "'"+var1+"','"+var2'"+","+var3

the above is much more readable as

print "'%s', '%s', %s" % (var1, var2, var3)



More information about the Python-list mailing list