diff Lib/stringold.py @ 5244:247139d200e8 legacy-trunk

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().
author Guido van Rossum <guido@python.org>
date Wed, 02 Apr 1997 05:49:46 +0000
parents 5b407e0cbc71
children 071a0d3a49b9
line wrap: on
line diff
--- a/Lib/stringold.py	Wed Apr 02 05:47:39 1997 +0000
+++ b/Lib/stringold.py	Wed Apr 02 05:49:46 1997 +0000
@@ -321,18 +321,8 @@
 	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,