Stupid string.split question

Brian Kelley bkelley at wi.mit.edu
Thu Aug 7 10:27:50 EDT 2003


Andrew Dalke wrote:

> Instead, he is bothered because the following doesn't work
> when sep == ""
> 
> def split_join(s, sep):
>   return s == sep.join(s.split(sep)):
> 
That's pretty much it.  Note that I'm not bothered so much to actually 
do anything about it :)

I understand the infinite number of empty seperators though, and while 
it might give pause I wonder (as an academic excercise) if you asked 100 
people what "ABCDEF".split('') should return (if it returned anything at 
all) what you would get.  Again, don't bother answering this question, 
list("ABCDEF") works just fine for me :)

Now, as for old chesnuts and long hot summers, if one could just do:

"".join(list("ABCDEF").reverse())

*ducks*





More information about the Python-list mailing list