> On 19 Mar 2020, at 22:12, Rob Cliffe <rob.cli...@btinternet.com> wrote:
> 
> 
> On 18/03/2020 20:16, Barry Scott wrote:
>> 
>>> On 18 Mar 2020, at 18:03, Rob Cliffe via Python-ideas 
>>> <python-ideas@python.org> wrote:
>>> 
>>> Consider that the start or end of a string may contain repetitions of an 
>>> affix.
>>> 
>>> Should `-+-+-+Spam'.stripprefix('-+')  remove just the first occurence?  
>>> All of them?  Does it need a 'count' parameter?
>> The only ways to use this function without counting is remove 1 prefix or 
>> remove all.
>> As Alex said 1 prefix is the common case. For the all case there are 
>> existing ways to do it.
>> 
>> If you are counting the number of prefix occurrences that exist you can 
>> simple slice the answer
>> without the strip prefix function.



>> 
>> Barry
> 
> I don't understand the last sentence.  I had in mind a case where you might 
> want to remove repetitions of an affix without knowning how many there were 
> (possibly none).

Yep could have worded better. I was wonder what example would need the count 
and if when you have the count its
easy to solve another way. I'm less sure have thought more about it.

As you noted later str.replace() has a count. So why by prefix/suffix striping?

Barry

> 
> Rob Cliffe
> 
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/U7FAFYLLFFAQVT64P3VRGA6RPWNBMO5L/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to