From 3ae811b57d227a220f207869487fd9251e278608 Mon Sep 17 00:00:00 2001 From: Hye-Shik Chang Date: Mon, 15 Dec 2003 18:49:53 +0000 Subject: Add rsplit method for str and unicode builtin types. SF feature request #801847. Original patch is written by Sean Reifschneider. --- Lib/string.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/string.py') diff --git a/Lib/string.py b/Lib/string.py index 0a77f461ff..bc10c20337 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 -- cgit v1.2.1