[issue5416] str.replace does strange things when given a negative count
Senthil
report at bugs.python.org
Wed Mar 4 16:04:58 CET 2009
Senthil <orsenthil at gmail.com> added the comment:
And also look at the help on string.replace which sets -1 as the
default value for maxsplit optional argument and which again defaults
to replace-all.
Clearly, maxsplit= -1 is not equal to maxsplit = 0.
replace(s, old, new, maxsplit=-1)
replace (str, old, new[, maxsplit]) -> string
Return a copy of string str with all occurrences of substring
old replaced by new. If the optional argument maxsplit is
given, only the first maxsplit occurrences are replaced.
- Daniel, thanks for digging this out from Py2.4, unless we get an
rationale behind this change, my only though on this issue was -
document the maxsplit argument saying that -1 defaults to replace
all.
----------
nosy: +orsenthil
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5416>
_______________________________________
More information about the Python-bugs-list
mailing list