On Tue, May 19, 2020 at 9:00 AM computermaster360 . <computermaster360@gmail.com> wrote:
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) for c in chars):
    return txt[:-1]
  else:
    return txt

I would appreciate if str.split, str.lstrip, str.rsplit functions had a `maxstrip` argument, similar to the `maxsplit` argument of `str.split`, which would specify the maximum count of characters to be removed from the string. In case of `str.split` this maximum would apply to each side of the string separately.

Do you mean "str.strip, str.lstrip, str.rstrip"?