Bug or feature? 'abc'.split('') rejects empty separator
Paul Rubin
phr-n2002a at nightsong.com
Sun Feb 10 16:53:55 EST 2002
Erik Max Francis <max at alcyone.com> writes:
> > 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'
> > instead".
>
> 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.
That's the counter-argument. Time for a PEP. <wink>
More information about the Python-list
mailing list