summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2003-12-15 18:49:53 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2003-12-15 18:49:53 (GMT)
commit3ae811b57d227a220f207869487fd9251e278608 (patch)
treeccbc4b81578fa69e6bc65df8da4994bf9a4b6e49 /Lib/string.py
parentdce391cb398f4ce266d98130d10810a6a36617b3 (diff)
downloadcpython-3ae811b57d227a220f207869487fd9251e278608.zip
cpython-3ae811b57d227a220f207869487fd9251e278608.tar.gz
cpython-3ae811b57d227a220f207869487fd9251e278608.tar.bz2
Add rsplit method for str and unicode builtin types.
SF feature request #801847. Original patch is written by Sean Reifschneider.
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 0a77f46..bc10c20 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -121,6 +121,18 @@ def split(s, sep=None, maxsplit=-1):
return s.split(sep, maxsplit)
splitfields = split
+# Split a string into a list of space/tab-separated words
+def rsplit(s, sep=None, maxsplit=-1):
+ """rsplit(s [,sep [,maxsplit]]) -> list of strings
+
+ Return a list of the words in the string s, using sep as the
+ delimiter string, starting at the end of the string and working
+ to the front. If maxsplit is given, at most maxsplit splits are
+ done. If sep is not specified or is None, any whitespace string
+ is a separator.
+ """
+ return s.rsplit(sep, maxsplit)
+
# Join fields with optional separator
def join(words, sep = ' '):
"""join(list [,sep]) -> string