str.split() with empty separator

Xavier Ho contact at
Tue Sep 15 14:50:11 CEST 2009

On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt
<eckhardt at>wrote:

> "'abc'.split('')" gives me a "ValueError: empty separator".
> However, "''.join(['a', 'b', 'c'])" gives me "'abc'".
> Why this asymmetry? I was under the impression that the two would be
> complementary.

I'm not sure about asymmetry, but how would you implement a split method
with an empty delimiter to begin with? It doesn't make much sense anyway.

If you feel strongly to make it do what you want it to do, it might be a
good idea to submit it to Python-ideas mailing list, or such.

Otherwise, it doesn't hurt to iterate over the string and make use of them,
right? ;)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list