[Python-Dev] Death to string functions!

Barry A. Warsaw barry@digicool.com
Tue, 19 Dec 2000 10:46:55 -0500


>>>>> "CP" == Christopher Petrilli <petrilli@amber.org> writes:

    CP> So I was thinking about this whole thing, and wondering why it
    CP> was that seeing things like:

    CP>      " ".join(aList)

    CP> bugged me to no end, while:

    CP>      aString.lower()

    CP> didn't seem to look wrong. I finally put my finger on it, and
    CP> I haven't seen anyone mention it, so I guess I'll do so.

Actually, it has been debated to death. ;)  This looks better:

    SPACE = ' '
    SPACE.join(aList)

That reads good to me ("space-join this list") and that's how I always
write it.  That said, there are certainly lots of people who agree
with you.  You can't put join() on sequences though, until you have
builtin base-classes, or interfaces, or protocols or some such
construct, because otherwise you'd have to add it to EVERY sequence,
including classes that act like sequences.

One idea that I believe has merit is to consider adding join() to the
builtins, probably with a signature like:

    join(aList, aString) -> aString

This horse has been whacked pretty good too, but I don't remember
seeing a patch or a pronouncement.

-Barry