str.split() with empty separator

Xavier Ho contact at xavierho.com
Tue Sep 15 08:50:11 EDT 2009


On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt
<eckhardt at satorlaser.com>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? ;)

Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090915/08140ce0/attachment-0001.html>


More information about the Python-list mailing list