def markup_join(seq):
 buf = []
 iterator = imap(soft_unicode, seq)
 for arg in iterator:
  buf.append(arg)
  if hasattr(arg, '__html__'):
   return Markup(u'').join(chain(buf, iterator))
 return concat(buf)

def markup_join ( seq ) : buf = [ ] iterator = imap ( soft_unicode , seq ) for arg in iterator : buf . append ( arg ) if hasattr ( arg , '__html__' ) : return Markup ( u'' ) . join ( chain ( buf , iterator ) ) return concat ( buf )
concatenation that escapes if necessary and converts to unicode .