[Python-ideas] a in x or in y

Chris Angelico rosuav at gmail.com
Thu Feb 13 20:35:47 CET 2014


On Fri, Feb 14, 2014 at 5:51 AM, Haoyi Li <haoyi.sg at gmail.com> wrote:
> I think we're talking about the wrong thing by focusing on whether we want
> "or in" or "or" or other finnicky syntax things. In terms of whether we can
> express the logic the OP wanted, we already can:
>
>>>> a = {1, 2, 3}
>>>> b = {4, 5, 6}
>>>> c = 5
>>>> c in a | b
> True
>
> ...
> Maybe we want to extend | to other sequences which in works on.

Most definitely. The 'in' operator is far broader than the set() type. Notably:

"somestring" in "wholesome" or in "string of words"

is not the same as concatenating the two strings and checking if the
target string is in the result.

ChrisA


More information about the Python-ideas mailing list