A common antipattern in Python is to concatenate a sequence of strings using
a + b
'%s%s' % (a, b)
There is nothing wrong in concatenating two strings with
+. Indeed it's easier to read than
You are right though that concatenating more than 2 strings with
+ is an O(n^2) operation (compared to O(n) for
join) and thus becomes inefficient. However this has not to do with using a loop. Even
a + b + c + ... is O(n^2), the reason being that each concatenation produces a new string.
CPython2.4 and above try to mitigate that, but it's still advisable to use
join when concatenating more than 2 strings.