string.join() syntax quirky?

François Pinard pinard at iro.umontreal.ca
Fri Nov 23 16:12:06 CET 2001


[Marcin 'Qrczak' Kowalczyk]

> Thu, 22 Nov 2001 18:51:07 GMT, Erik Johnson <ejohnso9 at earthlink.net> pisze:

> > is there a logical reason why it was implemented as a string method
> > rather than a list method?

> > Does it seem backwards to you or does it make intuitive sense to you?

> It seems backwards for me - the sequence is more important than the
> separator - but I wouldn't treat it as a list method either.  More as
> a global function.

You assertion about the sequence being much more important than the separator
is supported by Python designers of the string module.  The separator
is indeed optional in string.join(), and then implied to a single space.
It always looked ugly to me that it became mandatory in the new syntax, and
this ugliness always got me to think that there is something fundamentally
wrong with it, even if many clever people torn their mind at finding it nice.

Maybe that a mere built-in function "join(SEQUENCE)" should exist,
equivalent to "string.join(SEQUENCE)", a kind of "' '.join(SEQUENCE)"
where ' ' would have been made optional, and dropped. :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list