diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2004-08-07 17:41:54 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2004-08-07 17:41:54 (GMT) |
commit | 43ab0cd174c330d5338c395c1f1aae8a0aaffa2d (patch) | |
tree | 23fd1c2328e7821f584dfb769ec31bac28476540 /Lib/sre.py | |
parent | 5d9c3031c805ffb634688a6fcae0e7790688ce53 (diff) | |
download | cpython-43ab0cd174c330d5338c395c1f1aae8a0aaffa2d.zip cpython-43ab0cd174c330d5338c395c1f1aae8a0aaffa2d.tar.gz cpython-43ab0cd174c330d5338c395c1f1aae8a0aaffa2d.tar.bz2 |
[Bug #990792] Mention that repl can be a callable
Diffstat (limited to 'Lib/sre.py')
-rw-r--r-- | Lib/sre.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -139,7 +139,9 @@ def search(pattern, string, flags=0): 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""" + replacement repl. repl can be either a string or a callable; + if 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) def subn(pattern, repl, string, count=0): @@ -147,7 +149,9 @@ def subn(pattern, repl, string, count=0): new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of - substitutions that were made.""" + substitutions that were made. repl can be either a string or a + callable; if 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) def split(pattern, string, maxsplit=0): |