which is better, string concatentation or substitution?

John Salerno johnjsal at NOSPAMgmail.com
Mon May 8 00:09:11 EDT 2006


My initial feeling is that concatenation might take longer than 
substitution, but that it is also easier to read:


def p(self, paragraph):
     self.source += '<p>' + paragraph + '</p>\n\n'

vs.

def p(self, paragraph):
     self.source += '<p>%s</p>\n\n' % paragraph



Is there a preference between these two ways?



More information about the Python-list mailing list