[Python-Dev] backporting string changes to 2.2.3

Boris Boutillier boris.boutillier@arteris.net
11 Apr 2003 17:04:45 +0200

I see, I didn't think about all the documentations to update, and i
should have as I've got the same problem in my project :).

> I think the reason is that there isn't enough need for it.  The
> special case of s.rsplit(c, 1) can be coded so easily by using rfind()
> that I don't see the need to add it.  Our Swiss Army Knife string type
> is beginning to be so loaded with features that I am reluctant to add
> more.  The cost of a new feature these days is measured in the number
> of books that need to be updated, not the number of lines of code
> needed to implement it.
> For your amusement only (! :-), I offer this implementation of
> rsplit(), which works in Python 2.3:
> def rsplit(string, sep, count=-1):
>     L = [part[::-1] for part in string[::-1].split(sep[::-1], count)]
>     L.reverse()
>     return L
Didn't thought about this one, tricky and amusing.

Boris Boutillier - Boris.Boutillier@arteris.net