Author vstinner
Recipients eric.araujo, eric.smith, ezio.melotti, mindauga, mmilkin, mrabarnett, python-dev, rhettinger, terry.reedy, umi, vstinner
Date 2014-10-29.16:09:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414598961.98.0.867627597049.issue11957@psf.upfronthosting.co.za>
In-reply-to
Content
I suggest to make the 2 last parameters of re.sub(), re.subn() and re.split() parameters as keyword-only. It will break applications using count and maxsplit parameters as index parameters, but it's easy to fix these applications if they want to support also Python 3.5.

I checked Python 2.6: the name of the maxsplit and count parameters didn't change. So it's possible to write code working on Python 2.6-3.5 if the parameter name is explicitly used:

* re.sub("a", "a", "a", count=1)
* re.subn("a", "a", "a", count=1)
* re.split("a", "a", maxsplit=1)

The flags parameter was added to re.sub(), re.subn() and re.split() functions in Python 2.7:

* https://docs.python.org/2.7/library/re.html#re.sub
* https://docs.python.org/2.7/library/re.html#re.subn
* https://docs.python.org/2.7/library/re.html#re.split

See my attached re_keyword_only.patch:

* sub(), subn(): count and flags become keyword-only parameters
* split(): maxsplit and flags become keyword-only parameters
History
Date User Action Args
2014-10-29 16:09:22vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, eric.smith, ezio.melotti, eric.araujo, mrabarnett, python-dev, mindauga, mmilkin, umi
2014-10-29 16:09:21vstinnersetmessageid: <1414598961.98.0.867627597049.issue11957@psf.upfronthosting.co.za>
2014-10-29 16:09:21vstinnerlinkissue11957 messages
2014-10-29 16:09:21vstinnercreate