Чи є у Python швидкий спосіб заміни рядків, але замість того, щоб починати з початку, як replaceце робиться, починаючи з кінця? Наприклад:
>>> def rreplace(old, new, occurrence)
>>> ... # Code to replace the last occurrences of old by new
>>> '<div><div>Hello</div></div>'.rreplace('</div>','</bad>',1)
>>> '<div><div>Hello</div></bad>'