I would not want to overload plain strings' .__contains__() method to mean "has this substring OR matches this compiled regex." Besides being on a likely performance path, it's too special. And what about glob patterns, for example? Those too?

But you can wrap your strings in RegexSearchableString or something, and customize the behavior of that class however you like.

On Sun, Oct 13, 2019, 2:20 PM Steve Jorgensen <stevej@stevej.name> wrote:
I see that __contains__ is not a new thing, so I'm not sure why I didn't notice it. Thanks very much for pointing it out. :)
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4WKKTR3AR5VONLB6KHKJBXNJVA5ILKSK/
Code of Conduct: http://python.org/psf/codeofconduct/