summaryrefslogtreecommitdiff
path: root/Lib/string.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-02 05:49:46 +0000
committerGuido van Rossum <guido@python.org>1997-04-02 05:49:46 +0000
commit8b78767e834ac9f8d019aefa8c8379fd0bc80b23 (patch)
treed3a9c71fc4a666082a0af5acfee159bfdecf2232 /Lib/string.py
parent1a08a4938dad77733c82660656657958b9d1fa42 (diff)
downloadcpython-8b78767e834ac9f8d019aefa8c8379fd0bc80b23.tar.gz
Changed my mind on replace().
It's now replace(str, old, new, maxsplit=0). Note new ordering of parameters (string first); this is more consistent with translate().
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 8207a8ea97..99e72751a2 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -321,18 +321,8 @@ def maketrans(fromstr, tostr):
return joinfields(L, "")
# Substring replacement (global)
-def replace(old, new, str):
- return joinfields(splitfields(str, old), new)
-
-# Substring replacement (1st substring only)
-def replace1(old, new, str, i=0, last=None):
- if last is None:
- i = find(str, old, i)
- else:
- i = find(str, old, i, last)
- if i >= 0:
- str = str[:i] + new + str[i+len(old):]
- return str
+def replace(str, old, new, maxsplit=0):
+ return joinfields(splitfields(str, old, maxsplit), new)
# Try importing optional built-in module "strop" -- if it exists,