[Python-Dev] "funny".split("")
David Abrahams
David Abrahams" <david.abrahams@rcn.com
Tue, 12 Mar 2002 15:16:45 -0500
----- Original Message -----
From: "Tim Peters" <tim@zope.com>
To: <python-dev@python.org>
Sent: Tuesday, March 12, 2002 3:09 PM
Subject: RE: [Python-Dev] "funny".split("")
> 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.
That seems to come from the assumption that splitting on the empty
string is nonsense, whereas it obviously made sense to Christian (and
me).
> This is the way re.split() works too, given an empty "separator".
So fix it ;-)
> Other people think at least two other behaviors "are obvious" in this
silly
> case. That makes raising an exception most Pythonic to me.
Not that I think this is terribly important, but it seems to me that
it's cleaner to tell the people who think it's nonsensical "don't do
that" and give the rest the behavior they expect.
adding-zero-doesn't-make-much-sense-either-ly y'rs,
Dave
P.S. No, the obvious analogy to division by zero doesn't escape me.