Small inconsistency between string.split and "".split

Carlos Ribeiro carribeiro at gmail.com
Mon Sep 13 14:09:59 EDT 2004


On Mon, 13 Sep 2004 10:59:27 -0700, Inyeol Lee <inyeol.lee at siimage.com> wrote:
> I think "None" trick was documented here since string method was
> introduced.

I got it now. The problem is that I had just read the docstring --
yes, not the manual, and admit it, it was lazyness of my part ;-) But
anyway... the keyword parameter handling is inconsistent, *and* the
docstring could mention something about sep="None". Here it is:

split(s [,sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string s, using sep as the
    delimiter string.  If maxsplit is given, splits at no more than
    maxsplit places (resulting in at most maxsplit+1 words).  If sep
    is not specified, any whitespace string is a separator.

    (split and splitfields are synonymous)

It seems that sep=None can be safely understood as "sep is not
specified". The other way round is not so clear.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list