On Fri Jan 24 2014 at 11:55:57 PM, Georg Brandl <g.brandl@gmx.net> wrote:
There was also the suggestion on stackoverflow of

'x'.join('aaa'.rsplit('aa', 1))

which might be faster and less colon-y, but is very good at covering up the
real purpose of the code :)

Which is why you throw it in a clearly named function.

def rreplace(haystack, needle, replacement, count):
    """Replace the N rightmost occurrences of one string with another."""
    replacement.join(haystack.rsplit(needle, count))