String split

Fredrik Lundh fredrik at pythonware.com
Tue Mar 28 17:03:06 CEST 2006


Michele Petrazzo wrote:

> I don't understand why split (string split) doesn't work with the same
> method if I can't pass values or if I pass a whitespace value:
>
> >>> "".split()
> []
> >>> "".split(" ")
> ['']
>
> But into the doc I see:
> """ If sep is not specified or is None, any whitespace string is a
> separator.
> """
>
> In this two cases, split would to return the _same_ result?

split(None) strips the string before splitting it (on runs of whitespace,
not on individual whitespace characters).  see the library reference for
a complete description:

    http://docs.python.org/lib/string-methods.html

</F>






More information about the Python-list mailing list