I missed the point of your question, my answer was about False replacement as I hadn't precised it previously.
So now that I understand your question, yes you're right there's an issue here. This pleads in the direction of two new methods: prefix() and suffix(). As PEP 616 just added the two new methods removeprefix() and removesuffix(), it seems possible to do it. I personally think that prefix() and suffix() have more usecases than this ones. Florent Le lun. 9 août 2021 à 07:02, Serhiy Storchaka <[email protected]> a écrit : > > 09.08.21 05:05, [email protected] пише: > > This is a proposal to change the behaviour of the startswith() and > > endswith() methods for str, bytes and bytearray objects, making them > > return the matched value instead of the True boolean. > > And what should it return for empty matched value? > > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/TIJOYJZVGEED3WG4LDPBPUSHMQL6T3AI/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- FLOSS Engineer & Lawyer _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/AXHOMHOAHJGEWP6GSE3FMIWGJGIOD7TD/ Code of Conduct: http://python.org/psf/codeofconduct/
