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

Christian Tismer tismer@tismer.com
Tue, 12 Mar 2002 19:28:19 +0100


Brian Quinlan wrote:

> Christian 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 would expect
>>
>>   ['f','u','n','n','y']
>>
> 
> Why wouldn't you expect this: 
> ['', 'f', 'u', 'n', 'n', 'y', '']
> 
> As with:
> 
>>>>' f u n n y '.split(' ')
>>>>
> ['', 'f', 'u', 'n', 'n', 'y', '']


Good example.
I didn't think of this and expected it were obvious to
use the maximum string of single characters in this
case. But see my other post, I already accepted
list("funny") as the cleaner way.

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