I come to praise .join, not to bury it...

Alex Martelli aleaxit at yahoo.com
Tue Mar 6 04:25:28 EST 2001


"Huaiyu Zhu" <hzhu at users.sourceforge.net> wrote in message
news:slrn9a89dk.2rm.hzhu at rocket.knowledgetrack.com...
> It is all nice and well to say that sep.join(list) is good for
polymorphism,
> except that there are several practical annoyances:
>
> 1. The word join can be either transitive or nontransitive:
>    sep joins list.
>    list joins with sep.

The first way one tries to parse a method-name is as the
imperative form of some verb -- transitive if it takes
arguments, intransitive if it's without arguments.  I am
not a native speaker of English, but I strongly suspect
this generalizes to those who are.

> 2. Can we really join all kinds of lists?

We can join any kind of sequence which defines a length,
with some irregularities and bugs (regarding, not the
sequence itself, but the types of its _items_) depending
on the kind of joiner object: when the joiner object is
a single-byte string, the items must also be (unicode
object items are supposed to be accepted too, but there
is a bug in Python 2.0 which interferes sometimes); when
the joiner object is a Unicode string, the items may be
any object that defines a way to make it into Unicode
(in Python 2, e.g., an instance object with a __str__
method).

I hope some of these irregularities go away in 2.1...:-).


Alex






More information about the Python-list mailing list