If its treated as a missing parameter, and currently doesn't do anything,
then it wouldn't be used... right? and it could be safe to add behavior for
it... right?

On Thu, Jul 19, 2018 at 11:17 AM, Eric V. Smith <e...@trueblade.com> wrote:

> On 7/19/2018 10:01 AM, Calvin Spealman wrote:
>
>> As an alternative suggestion: What if the count parameter to
>> str.replace() counted from the right with negative values? That would be
>> consistent with other things like indexing and slicing.
>>
>
> We couldn't make this change because negative values already have a
> meaning: it's interpreted as a missing parameter:
>
> >>> 'abab'.replace('a', 'z')
> 'zbzb'
> >>> 'abab'.replace('a', 'z', 0)
> 'abab'
> >>> 'abab'.replace('a', 'z', 1)
> 'zbab'
> >>> 'abab'.replace('a', 'z', -1)
> 'zbzb'
> >>> 'abab'.replace('a', 'z', -2)
> 'zbzb'
> >>> 'abab'.replace('a', 'z', -100)
> 'zbzb'
>
> I think .rreplace() is the better design.
>
> Eric
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to