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 <[email protected]> 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 -- [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/4WKKTR3AR5VONLB6KHKJBXNJVA5ILKSK/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ 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/LVBITR4GNCDS6KOK2CSGRS2IQHOLBVO2/ Code of Conduct: http://python.org/psf/codeofconduct/
