diff options
author | Guido van Rossum <guido@python.org> | 2000-03-10 23:22:10 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-10 23:22:10 (GMT) |
commit | 8f0c5a774225adb71a02256be02a9fce0fd601a9 (patch) | |
tree | c0f1c83b99191aeac0eb55b443f04fbc7e0dc84e /Lib/string.py | |
parent | 0612d8415540a881a38a3abfa5d86a23f488b230 (diff) | |
download | cpython-8f0c5a774225adb71a02256be02a9fce0fd601a9.zip cpython-8f0c5a774225adb71a02256be02a9fce0fd601a9.tar.gz cpython-8f0c5a774225adb71a02256be02a9fce0fd601a9.tar.bz2 |
Marc-Andre Lemburg: the maxsplit argument for split() and replace()
now defaults to -1, not to 0. Passing an explicit zero doesn't split
or replace at all.
Diffstat (limited to 'Lib/string.py')
-rw-r--r-- | Lib/string.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/string.py b/Lib/string.py index 8d6d622..5eb5697 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -97,13 +97,13 @@ def rstrip(s): # Split a string into a list of space/tab-separated words # NB: split(s) is NOT the same as splitfields(s, ' ')! -def split(s, sep=None, maxsplit=0): +def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the - delimiter string. If maxsplit is nonzero, splits into at most + delimiter string. If maxsplit is given, splits into at most maxsplit words. If sep is not specified, any whitespace string - is a separator. Maxsplit defaults to 0. + is a separator. (split and splitfields are synonymous) @@ -396,7 +396,7 @@ def maketrans(fromstr, tostr): return joinfields(L, "") # Substring replacement (global) -def replace(s, old, new, maxsplit=0): +def replace(s, old, new, maxsplit=-1): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring |