]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#4185: clarify escape behavior of replacement strings.
authorGeorg Brandl <georg@python.org>
Thu, 1 Jan 2009 12:00:19 +0000 (12:00 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 1 Jan 2009 12:00:19 +0000 (12:00 +0000)
Lib/re.py

index ee962bbc8f85bb4c94faa18ca5b8f2310d7f65bd..2cf7132d3d9e45311b646f64f3d632a509586c10 100644 (file)
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -145,7 +145,8 @@ def sub(pattern, repl, string, count=0):
     """Return the string obtained by replacing the leftmost
     non-overlapping occurrences of the pattern in string by the
     replacement repl.  repl can be either a string or a callable;
-    if a callable, it's passed the match object and must return
+    if a string, backslash escapes in it are processed.  If it is
+    a callable, it's passed the match object and must return
     a replacement string to be used."""
     return _compile(pattern, 0).sub(repl, string, count)
 
@@ -155,7 +156,8 @@ def subn(pattern, repl, string, count=0):
     non-overlapping occurrences of the pattern in the source
     string by the replacement repl.  number is the number of
     substitutions that were made. repl can be either a string or a
-    callable; if a callable, it's passed the match object and must
+    callable; if a string, backslash escapes in it are processed.
+    If it is a callable, it's passed the match object and must
     return a replacement string to be used."""
     return _compile(pattern, 0).subn(repl, string, count)