Bug or feature? 'abc'.split('') rejects empty separator
Luca Fini
lfini at arcetri.astro.it
Fri Feb 15 07:04:13 EST 2002
On Mon, 11 Feb 2002, David C. Ullrich wrote:
> On Sun, 10 Feb 2002 18:05:01 -0500, "Tim Peters" <tim.one at home.com>
> wrote:
>
> >[Bengt Richter]
> >> >>> 'abc'.split('')
> >> Traceback (most recent call last):
> >> File "<stdin>", line 1, in ?
> >> ValueError: empty separator
> >>
> >> Wouldn't it make sense to return list('abc') ?
> >
> >[Neil Schemenauer]
> >> It would also make sense to return ['a', 'b', 'c'].
> >
My 2 cent worth opinion is that it should return ['a', 'b', 'c'].
The characters are separated by "nothing". It also would maintain simmetry
with join() which is not bad.
BTW: this is how the corresponding functions work in perl. Maybe this is a
reason to do it differently ;-)
--
--------------------------------------------------------------------------
-- ) Luca Fini Tel: +39 055 2752 307
___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292
/ | | |-_ L.go E.Fermi, 5 +-----------------------------------------
(___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini
(_) (_) Italia / e-mail: lfini at arcetri.astro.it
-----------------------------+--------------------------------------------
More information about the Python-list
mailing list