Issue 14081: Allow "maxsplit" argument to str.split() to be passed as a keyword argument (original) (raw)

Created on 2012-02-22 01:54 by ncoghlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue14081.diff ezio.melotti,2012-02-22 03:16 Patch + tests review
issue14081-2.diff ezio.melotti,2012-02-24 10:30
Messages (7)
msg153920 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2012-02-22 01:54
Currently, setting maxsplit for the default "any whitespace" behaviour requires the following cryptic incantation: 'do re mi fa'.split(None, 1) That would be significantly more comprehensible as: 'do re mi fa'.split(maxsplit=1) (I noticed this when trying to figure out why http://hyperpolyglot.org/scripting#split-notes resorted to using the re module to achieve this)
msg153924 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-02-22 03:16
+1 Patch attached.
msg154130 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-02-24 10:30
New patch that changes .rsplit() too and updates docs and docstrings.
msg154194 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-25 07:16
LGTM. (Nick: I think the author directly translated the regex function calls from other languages to using re in Python.)
msg154222 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2012-02-25 09:41
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.
msg154311 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-26 07:40
New changeset db968ac2b82c by Ezio Melotti in branch 'default': #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
msg154312 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-02-26 07:44
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.)
History
Date User Action Args
2022-04-11 14:57:27 admin set github: 58289
2012-02-26 07:44:14 ezio.melotti set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2012-02-26 07:40:08 python-dev set nosy: + python-devmessages: +
2012-02-25 09:41:45 ncoghlan set messages: +
2012-02-25 07:16:24 eric.araujo set nosy: + eric.araujomessages: +
2012-02-24 16:05:25 tshepang set nosy: + tshepang
2012-02-24 10:31:00 ezio.melotti set files: + issue14081-2.diffmessages: +
2012-02-22 03:16:52 ezio.melotti set files: + issue14081.diffassignee: ezio.melottikeywords: + patchnosy: + ezio.melottimessages: + stage: needs patch -> commit review
2012-02-22 01:54:09 ncoghlan create