Small inconsistency between string.split and "".split

Carlos Ribeiro carribeiro at
Mon Sep 13 18:57:27 CEST 2004

Hi all,

While writing a small program to help other poster at, I found
a small inconsistency between the handling of keyword parameters of
string.split() and the split() method of strings. I wonder if someone
else had ever stumbled on it before, and if it has a good reason to
work like it is.

Both implementations take two parameters: the separator character and
the max number of splits (maxsplit). However, string.split() accept
maxsplit as a keyword parameter, while mystring.split() doesn't. In my
case, it meant that I had to resort to string.split() in my example,
in order to avoid having to deal with the separator.

** BTW, I had to avoid dealing with the separator for another annoying
reason: I thought that I could do something like this:

mystring.split(string.whitespace, 2)

to preserve the default whitespace detecting behavior. But it won't
work this way with neither implementation of split().

Carlos Ribeiro
Consultoria em Projetos
mail: carribeiro at
mail: carribeiro at

More information about the Python-list mailing list