[New-bugs-announce] [issue1176] str.split() takes no keyword arguments (Should this be expected?)

Sergio Correia report at bugs.python.org
Tue Sep 18 18:59:52 CEST 2007


New submission from Sergio Correia:

str.split() does not accept maxsplits as a keyword argument.

If i want to split a string, and, say, get its first word, I do this:

>>> 'SPAM eggs eggs spam spam ham'.split(None, 1)[0]
'SPAM'

However, as documented on help(str.split), the separator is optional, so
 I expected this to work:

>>> 'SPAM eggs eggs spam spam ham'.split(maxsplit=1)

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    'SPAM eggs eggs spam spam ham'.split(maxsplit=1)
TypeError: split() takes no keyword arguments

I feel allowing keyword arguments is convenient, but is there a reason
behind not allowing them?

----------
components: Library (Lib)
messages: 56002
nosy: sergioc
severity: minor
status: open
title: str.split() takes no keyword arguments (Should this be expected?)
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1176>
__________________________________


More information about the New-bugs-announce mailing list