[Python-ideas] str.rreplace

MRAB python at mrabarnett.plus.com
Fri Jan 24 22:04:22 CET 2014


On 2014-01-24 20:48, Chris Angelico wrote:
> On Sat, Jan 25, 2014 at 7:33 AM,  <random832 at fastmail.us> wrote:
>>>>>'aaa'[::-1].replace('aa'[::-1],'x'[::-1])[::-1]
>> 'ax'
>
> It makes me happy when the [::-1] smiley gets used that many times to
> solve a problem. Very happy.
>
> Happy that it isn't in _my_ code, to be precise...
>
It's probably not as efficient, either!

And if we're going to do it that way, do we really need .rindex and
.rfind? Or .rstrip (we could use .lstrip)?



More information about the Python-ideas mailing list