On Tue, Mar 24, 2020 at 08:14:33PM -0000, Dennis Sweeney wrote: > I think then maybe it would be preferred to > use the something like the following in the PEP: > > def cutprefix(self, prefix, /): > if isinstance(prefix, str): > if self.startswith(prefix): > return self[len(prefix):] > return self[:]
Didn't we have a discussion about not mandating a copy when nothing changes? For strings, I'd just return `self`. It is only bytearray that requires a copy to be made. > elif isinstance(prefix, tuple): > for option in prefix: > if self.startswith(option): > return self[len(option):] I'd also remove the entire multiple substrings feature, for reasons I've already given. "Compatibility with startswith" is not a good reason to add this feature and you haven't established any good use-cases for it. A closer analog is str.replace(substring, ''), and after almost 30 years of real-world experience, that method still only takes a single substring, not a tuple. -- Steven _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/4CL4G4OY2DREUVSOHCYFDLCWGBQ6ULLD/ Code of Conduct: http://python.org/psf/codeofconduct/