Bug or feature? 'abc'.split('') rejects empty separator
Erik Max Francis
max at alcyone.com
Sun Feb 10 22:48:09 CET 2002
Paul Rubin wrote:
> It seems to me like the principle that programs should be able to "do
> nothing" gracefully. The argument is that split should be the inverse
> of join, even when the splitting string is empty.
> Imagine if "a+0" raised an error. You wouldn't say "just use 'a'
That is simply not comparable. The purpose of split is to divide up a
string according to a delimiter. Asking for it to split a string given
a null delimiter doesn't make much sense at all; if you're calling
string.split with the intent of dividing it up and you're passing in ''
as a delimiter, that's almost certainly a mistake. If you really _do_
want the equivalent of list(string), then you might as well have just
done that in the first place.
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.
Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
An Esperanto reference for English speakers.
More information about the Python-list