On Mar 11, 2005, at 18:18, Raymond Hettinger wrote:
> str.join() is still the best practice for string concatenation.
...except you actually need unicode.join if the strings are of that
kind. Fortunately, ''.join intrinsically compensates:
>>> x=[u'\u0fe0']*2
>>> ''.join(x)
u'\u0fe0\u0fe0'
*without* (as one would expect) the GD nuisance of converting x's items
to str (hellishly hard to document accurately and clearly, but
extremely convenient!-).
Which reminds me -- could we have a methodcaller relative to attrgetter
and itemgetter? "Sort a list of strings in a case-insensitive way"
would become *SO* easy with sort(dalist, key=methodcaller('lower'))...
can't REALLY recommend sort(dalist, key=str.lower) then the items of
dalist MIGHT be either str or unicode items... (the relevance of
''.join is that it proves SOMEbody considered it important to deal with
a list of either str or unicode in the joining context... why not in
the sorting context then?).
Alex