> if foo OR bar OR baz in foobar:
>     pass
>

Someone else noted, and I agreed, that set intersection is already the
obvious way to do this. But yes, some things aren't hashable. So in concept
you could make a custom type that had some set-like behaviors, and so on.

But all of this is crazy work for a pattern that really isn't that common,
in my experience. The obvious answer doesn't disrupt anything: just write a
FUNCTION:

if any_in((foo, bar, baz), foobar): ...

That's completely obvious and needs no change. Heck, write all_in(),
most_in(), and at_least_n_in(), while you are at it. None need syntax, all
variations take 2-5 lines of code each, depending on implementation.

>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/YLOLTSYNM4QONOQ5MWDLUFKB5CQ452BV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to