[Python-ideas] is in operator

Mathias Panzenböck grosser.meister.morti at gmx.net
Thu Sep 27 14:18:24 CEST 2007

George Sakkis wrote:
> Or in a more obfuscated way:
> import operator as op
> from itertools import imap
>>from functools import partial
> if any(imap(partial(op.is_,x), (a, b, c))):
>         ...
> if all(imap(partial(op.is_not,x), (a, b, c))):
>      ...
> George

Or in haskell (assuming haskell would have "is" and "is not"):

if any (x is) [a, b, c] then ... else ...

if all (x is not) [a, b c] then ... else ...

I'm not sure if "any" and "all" are the ones with 2 parameters (function and list) or
if that would be "or" and "and".


More information about the Python-ideas mailing list