This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients acg, ezio.melotti, rhettinger, terry.reedy
Date 2011-11-13.03:04:51
SpamBayes Score 4.3941122e-06
Marked as misclassified No
Message-id <>
The two methods are defined differently, and act as defined, so this is a feature request, not a bug report.

str.split([sep[, maxsplit]]) 
... If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is not specified, then there is no limit on the number of splits (all possible splits are made).

re.split(pattern, string, maxsplit=0, flags=0)
...If maxsplit is nonzero, at most maxsplit splits occur,

Clearly, if maxsplit for re.split is the default of 0, it must do all splits. There is a difference between being optional with no default (possible with C-coded functions) and with a default.

Logically, both should have a default of None, meaning no limit. But I agree with Ezio and do not see that happening for Python 3.

As for negative values, I would have maxsplit treated as a count and make negative values a ValueError.
Date User Action Args
2011-11-13 03:04:52terry.reedysetrecipients: + terry.reedy, rhettinger, ezio.melotti, acg
2011-11-13 03:04:52terry.reedysetmessageid: <>
2011-11-13 03:04:51terry.reedylinkissue13346 messages
2011-11-13 03:04:51terry.reedycreate