Small inconsistency between string.split and "".split
carribeiro at gmail.com
Mon Sep 13 18:57:27 CEST 2004
While writing a small program to help other poster at c.l.py, 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:
to preserve the default whitespace detecting behavior. But it won't
work this way with neither implementation of split().
Consultoria em Projetos
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com
More information about the Python-list