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

Christian Tismer tismer@tismer.com
Tue, 12 Mar 2002 20:16:36 +0100


David Abrahams wrote:

> There's a reason to pursue the OP's expected result as opposed to just
> settling for list("funny"). If we pick a reasonable behavior for this
> case, it will save some number of people from having to write:
> 
>     if len(sep):
>         divided = s.split(sep)
>     else:
>         divided = list(s)
> 
> Which just makes the code harder-to-read.
> 
> What's the point in making s.split('') an error? Assuming you document
> the behavior, the only people served by the error message are people who
> haven't bothered to read the docs. However, their code is broken anyway.
> 
> Causing an error when there's the slightest ambiguity in what the code
> might mean in the absence of documentation doesn't serve anyone. I think
> the introduction of the MRO is in part motivated by this philosophy, and
> it's a good idea, when there's a sensible non-error behavior, to
> implement it.


I'll keep my fingers crossed - 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/