Small inconsistency between string.split and "".split

Carlos Ribeiro carribeiro at gmail.com
Tue Sep 14 10:30:14 EDT 2004


Walter,

On Tue, 14 Sep 2004 12:01:29 +0200, Walter Dörwald
<walter at livinglogic.de> wrote:
> Carlos Ribeiro wrote:
> I've fixed the docstring for both unicode.split() and
> string.split() to give a hint about the None default. Note
> that the docstring for str.split() already *did* mention
> the None option.

I don't know if you can do it, but isn't easy to modify the split
method to accept maxsplit as a keyword parameter? It would make it
consistent with string.split(), and as far as I'm aware, it should not
cause any sizeable performance penalty. But the most important reason
is that keyword parameters for often-unused options make code more
readable; for example,

    mystring.split(maxsplit=2)

reads better than:

   mystring.,split(None, 2)

That's my opinion, anyway...

-- 
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