#NEWLINE# def rreplace( s , old , new , occurences = ( - 1 ) ) : #NEWLINE# #INDENT# "Replace all occurencens of 'old' with 'new'\n    starting at the right hand side of the string. If occurences\n    is specified, the number of replacements is limited to\n    occurences.\n\n    :param s: the input string\n    :type s: string\n    :param old: the string that will be replaced\n    :type old: string\n    :param new: the replacement string\n    :type new: string\n    :param occurences: the maximal number of replacements\n    :type occurences: integer\n    " #NEWLINE# li = s . rsplit ( old , occurences ) #NEWLINE# return new . join ( li )