String formatting is faster and more readable, always.
Consider using named parameters, and the more recent str.format()
method:
"<{tag}>{value}</{tag}>{tail}".format(tag='foo', value='bar', tail='spam')
Domanda
Which string implementation in python is more pythonic?
string += "<%s>%s</%s>%s" % (a, b, c, d)
or
string += '<' + a + '>' + b + '<'/' + c + '>' + d
Soluzione
String formatting is faster and more readable, always.
Consider using named parameters, and the more recent str.format()
method:
"<{tag}>{value}</{tag}>{tail}".format(tag='foo', value='bar', tail='spam')