[Python-ideas] Re: str.strip: argument maxstrip

2020-05-19 Thread computermaster360 .
Jonathan Goble wrote: > > Do you mean "str.strip, str.lstrip, str.rstrip"? Yes, I meant that. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] str.strip: argument maxstrip

2020-05-19 Thread computermaster360 .
I often find myself in a need of stripping only a specified amount of characters from a string (most commonly a single character). I have been implementing this in an ad-hoc manner, which is quite inelegant: def rstrip1(txt, chars): if txt is None: return None elif any(txt.endswith(c)