On 05/16/2013 11:15 AM, Chris Angelico wrote:
> On Fri, May 17, 2013 at 1:00 AM, loial <
jldun...@gmail.com> wrote:
> Try with a limit:
>
>>>> "HELLO_GOODBYE_xxxxxxxx.ls".rsplit("_",1)
> ['HELLO_GOODBYE', '
xxxxxxxx.ls']
>>>> "HELLO_GOODBYE_xxxxxxxx.ls".rsplit("_",1)[0]
> 'HELLO_GOODBYE'
>
> You can easily get docs on it:
>
>>>> help("".rsplit)
> Help on built-in function rsplit:
>
> rsplit(...)
> S.rsplit(sep=None, maxsplit=-1) -> list of strings
>
> Return a list of the words in 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, any whitespace string
> is a separator.
>
> ChrisA
>
the one case where that won't work. It's easy to test for, but still