string.join() syntax quirky?

François Pinard pinard at
Tue Nov 27 00:18:24 CET 2001

> > > One way to look at it [...]

> > So instead of doing what's right we're doing what's convenient? Doesn't
> > sound very Pythonic <wink>

> Another way to look at is is that joining and splitting are inherently
> string functionailty [...]

I still wonder why the string is optional for `string.join()' and
`string.split()'.  If it was inherent, the string would be prominent.
My belief is that people are looking for "one way to look at it" and
"another way to look at it", but this is still torture from clever minds.

> I don't think join() belongs with sequences at all, as sequences can
> hold anything, not just strings.

Right.  Nevertheless, I think we should keep our mind a bit relax, when
working with a pleasurable language.  Deep down, we are still joining
a sequence of strings into a resulting string with a separator; we just
never join a separator over a sequence of strings: this is ugly thinking.
No doubt that we can invent lots of justification for it, it stays ugly.

I just decided to have confidence in the collective wisdom, as many promised
all the others that we will get used to that ugliness.  The truth is that,
for one, I do not foresee the day I will get used to this one.  I guess
history will eventually list ''.join() together with lambda's, as being a
few poor choices that would have better been left out of the Python language.

Happily enough, there are nicer ways in Python.  But it is now less true that
it once was that There-Is-Only-One-Way-To-Do-It in Python.  Python became
a bit more Perlish by providing such ugly alternatives.  Moreover, through
this added diversity, in the long run, Python is triggering a little loss
in legibility (reading Python of others).  So, the decision stays debatable.

Of course, it will stay.  Newcomers will often inquire about that stain...

François Pinard

More information about the Python-list mailing list