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

Erik Max Francis max at alcyone.com
Sun Feb 10 18:01:52 EST 2002


Roy Smith wrote:

> I think it makes plenty of sense.

Sure, but your repeated opinion isn't going to change anything.  Since
that's how things work, the onus on you is to convince people that it
should be changed.  That you think it would be nice isn't very
convincing.

> If the delimter was written as a constant '', I might be inclined to
> agree,
> but it could be computed on the fly, and having a delimter of '' mean
> "split the thing up with nothing between the parts" is a very logical
> extension of the general idea.

That doesn't change the fact that it is likely a mistake and there's no
reason to do it, given that there are easier, clearer, and more direct
ways to get the effect that you want.

> Should we outlaw raising things to the zero power because somebody
> thinks
> it "doesn't make much sense at all"?  I'll be a lot of people think it
> doesn't make much sense, but the mathematicians would howl if you
> tried to
> take it away.

You can keep repeating this analogy but it doesn't apply.  x^0 is well
defined (with a questionable area if x = 0, but this isn't sci.math). 
Splitting a string by delimiter with no delimiter doesn't make much
sense, because in that case it's not clear what you mean, and you're
better off doing it otherwise.

-- 
 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