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

Erik Max Francis max at alcyone.com
Sun Feb 10 14:44:36 EST 2002


Bengt Richter wrote:

>  >>> 'abc'.split('')
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>  ValueError: empty separator
> 
> Wouldn't it make sense to return list('abc') ?

If that's what you really wanted, it would make far more sense to just
use list directly rather than calling string.split on the string.  The
error seems reasonable to me -- you shouldn't be using string.split if
that's what you really want.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Laws are silent in time of war.
\__/ Cicero
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.



More information about the Python-list mailing list