Edward Elliott <[EMAIL PROTECTED]> wrote: >bruno at modulix wrote: > >> Edward Elliott wrote: >>> You mean like this: >>> >>> s = "foo" + "bar" >>> s = 'foo' + 'bar' >>> s = 'foo' 'bar' >>> s = '%s%s' % ('foo', 'bar') >[snip] >> The real mantra is actually : >> "There should be one-- and preferably only one --obvious way to do it" >> >> Please note the "should", "preferably", and "obvious". > >Touche. Please tell me which of the above should obviously be the >preferable way to concatenate strings. All those weasel words prove my >point: it's a vague and watered-down guideline that gives way in the face >of other considerations.
Well, there's really no difference between the first two, and this would work just as well: s = """foo""" + '''bar''' The third line only works for string constants, not for string variables. IMHO, it would be the preferred method for concatenating string constants. At one time, it was said that the "%" operator was the fastest way to concatenate strings, because it was implemented in C, whereas the + operator was interpreted. However, as I recall, the difference was hardly measurable, and may not even exist any longer. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list