You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow "maxsplit" argument to str.split() to be passed as a keyword argument #58289
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ezio-melotti'closed_at=<Date2012-02-26.07:44:14.924>created_at=<Date2012-02-22.01:54:09.836>labels= ['interpreter-core', 'type-feature']
title='Allow "maxsplit" argument to str.split() to be passed as a keyword argument'updated_at=<Date2012-02-26.07:44:14.922>user='https://github.com/ncoghlan'
Ezio: I spotted an extraneous '[' hanging around in the updated doc signature for split, but otherwise looked fine.
Éric: you're probably right, but I was sending them a note to suggest a simpler alternative, only to discover that the obvious approach of "maxsplit=1" didn't actually work.
python-dev commented on Feb 26, 2012
python-devmannequin
Mannequin
More actions
New changeset db968ac2b82c by Ezio Melotti in branch 'default': bpo-14081: The sep and maxsplit parameter to str.split, bytes.split, and bytearray.split may now be passed as keyword arguments. http://hg.python.org/cpython/rev/db968ac2b82c
Fixed!
Thanks for the reviews and for spotting the extra '['.
(While suggesting the use of maxsplit, be aware that str.split uses -1 as default value, whereas re.split uses 0.)
Activity
ncoghlan commentedon Feb 22, 2012
Currently, setting maxsplit for the default "any whitespace" behaviour requires the following cryptic incantation:
That would be significantly more comprehensible as:
(I noticed this when trying to figure out why http://hyperpolyglot.org/scripting#split-notes resorted to using the re module to achieve this)
ezio-melotti commentedon Feb 22, 2012
+1
Patch attached.
ezio-melotti commentedon Feb 24, 2012
New patch that changes .rsplit() too and updates docs and docstrings.
merwok commentedon Feb 25, 2012
LGTM.
(Nick: I think the author directly translated the regex function calls from other languages to using re in Python.)
ncoghlan commentedon Feb 25, 2012
Ezio: I spotted an extraneous '[' hanging around in the updated doc signature for split, but otherwise looked fine.
Éric: you're probably right, but I was sending them a note to suggest a simpler alternative, only to discover that the obvious approach of "maxsplit=1" didn't actually work.
python-dev commentedon Feb 26, 2012
New changeset db968ac2b82c by Ezio Melotti in branch 'default':
bpo-14081: The sep and maxsplit parameter to str.split, bytes.split, and bytearray.split may now be passed as keyword arguments.
http://hg.python.org/cpython/rev/db968ac2b82c
ezio-melotti commentedon Feb 26, 2012
Fixed!
Thanks for the reviews and for spotting the extra '['.
(While suggesting the use of maxsplit, be aware that str.split uses -1 as default value, whereas re.split uses 0.)