[Python-Dev] "funny".split("")

Christian Tismer tismer@tismer.com
2002年3月12日 21:25:43 +0100


Tim Peters wrote:
> Last time this went around on comp.lang.python (I hope nobody believes this
> is a new discussion <wink>), my immediate gut reaction was that, *if*
> splitting on an empty string had to do something, it should "obviously"
> return the target string unchanged: you didn't specify a sensible
> separator, so nothing should get split. This is the way re.split() works
> too, given an empty "separator".
>> Other people think at least two other behaviors "are obvious" in this silly
> case. That makes raising an exception most Pythonic to me.

I didn'd follow c.l.py too long and wouldn't have asked
this question otherwise. The booklet just says *nothing*
about this case, and I wanted to add the final answer.
I have a one single opinion in this case:
Let things be as easy to remember as possible.
I'd do exactly what Perl does in this case, whatever
it is. Only one fact to learn.
-- 
Christian Tismer :^) <mailto:tismer@tismer.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net/
14163 Berlin : PGP key -> http://wwwkeys.pgp.net/
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
 where do you want to jump today? http://www.stackless.com/

AltStyle によって変換されたページ (->オリジナル) /