[Python-Dev] "funny".split("")
Christian Tismer
tismer@tismer.com
Tue, 12 Mar 2002 19:16:43 +0100
Gerald S. Williams wrote:
> Christian Tismer wrote:
>
>>I'm just translating the Python Pocked Reference the
>>second time, and I stumbled over this:
>> "funny".split("")
>>gives a ValueError: empty separator.
>>Why this?
>>
>
> I don't know, but I have a patch for stringobject.c and
> stropmodule.c that gives the behavior you asked for (I
> haven't done unicodeobject.c yet). Should I post it?
Thanks a lot!
But I think this is not a problem of implementation
but design. Since "hello".split("") would be the only
ambiguous case (you can find non-countable infinite
outputs which would yield the same join), they seem
to have decided to forbid it.
I (bummer head) would have choosen the obvious,
but having to replace the expression by list("hello")
is just fine with me, and for sure a bit cleaner.
ciao - chris
--
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/