On Mon, Aug 9, 2021 at 1:42 PM <[email protected]> wrote:
>
> 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.

Unfortunately this would break backward compatibility, since it's
currently guaranteed that they return precisely True or False, and
that can be used (eg) for indexing. To maintain that, you'd have to
create new methods which return the matched value or None (and can
then define startswith/endswith as the boolification of that). For
instance:

domain.findsuffix((".fr", ".com", ".org"))

ChrisA
_______________________________________________
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/722CDS6W3FKLPWF4TBGUBHOL2RA5LZUV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to