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 <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1176>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to