[Python-Dev] split('') revisited

Barry A. Warsaw barry@python.org
Wed, 31 Jul 2002 22:28:53 -0400

>>>>> "AK" == Andrew Koenig <ark@research.att.com> writes:

    AK> Back in February, there was a thread in comp.lang.python (and,
    AK> I think, also on Python-Dev) that asked whether the following
    AK> behavior:

    >> 'abcde'.split('')
    |         Traceback (most recent call last):
    |           File "<stdin>", line 1, in ?
    |         ValueError: empty separator

    AK> was a bug or a feature.  The prevailing opinion at the time
    AK> seemed to be that there was not a sensible, unique way of
    AK> defining this operation, so rejecting it was a feature.

    AK> That answer didn't bother me particularly at the time, but
    AK> since then I have learned a new fact (or perhaps an old fact
    AK> that I didn't notice at the time) that has changed my mind:
    AK> Section 4.2.4 of the library reference says that the 'split'
    AK> method of a regular expression object is defined as

    AK>         Identical to the split() function, using the compiled
    AK> pattern.

    AK> This claim does not appear to be correct:

Actually, I believe what it's saying is that


is the same as

    re.split('', 'abcde')

not that re...split() has anything to do with the split() string