string.join() syntax quirky?

Erik Johnson ejohnso9 at earthlink.net
Thu Nov 22 13:51:07 EST 2001


    I suppose this question is mostly moot because the language is what
it is (though Mr. van Rossum could always change or augment it at his
will), but I'll ask anyway...

After doing this:

s = "string"
l = list(s)
l.reverse()

    I have a list of single character strings. A couple of people were
kind enough to clue me in to the best way to turn this back to a string:

s = "".join(l)

    This works fine, but it seems syntactically backwards to me:

# s = l.join("")

makes much more sense to me. The thingy I want to do something to is my
list. I am just trying to learn Python, so no doubt there will be some
Python things I will just have to get used to, but 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? Comments? (other than of the "it's moot" flavor)

Thanks! :)
-ej




More information about the Python-list mailing list