Bug or feature? 'abc'.split('') rejects empty separator

Peter Hansen phansen at kaval.com
Sun Feb 10 20:39:58 EST 2002


Erik Max Francis wrote:
> 
> That's what list('abc') would return.  But in actuality, for it to be
> consistent with the rest of string.split's behavior, 'abc'.split('')
> would have to return ['', 'a', 'b', 'c', ''], not ['a', 'b', 'c'].
> 
> Another beautiful example of why string.split('') should raise an error
> instead of trying to guess what you mean.

And another:

>>> ''.join(['ab', 'c'])
'abc'

So what should 'abc'.split('') return again?



More information about the Python-list mailing list