split(None)

Emile van Sebille emile at fenx.com
Tue Nov 6 13:31:17 EST 2001


"Oliver Fromme" <olli at secnetix.de> wrote in message
news:9s98o6$ilj$1 at isp-m-srv06.izb.net...
> The library reference says the following about the "split"
> string method:
>
>  |  If sep is not specified or None, any whitespace string
>  |  is a separator.
>
> So I thought that foo.split() and foo.split(None) should
> return the same result.  However:
>
>    >>> "foo bar baz".split()
>    ['foo', 'bar', 'baz']
>
>    >>> "foo bar baz".split(None)
>    ['foo bar baz']
>

I don't get the same results.

F:\Python21>python
ActivePython 2.1, build 210 ActiveState)
based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> "foo bar baz".split(None)
['foo', 'bar', 'baz']
>>> "foo bar baz".split(None, 1)
['foo', 'bar baz']
>>>

It look to me like it works the way you would expect it to.


Emile van Sebille
emile at fenx.com





More information about the Python-list mailing list