[Python-ideas] a in x or in y
Ethan Furman
ethan at stoneleaf.us
Fri Feb 14 01:52:59 CET 2014
On 02/13/2014 03:32 PM, Haoyi Li wrote:
> Carl Meyer wrote:
>> This makes me think of
>>
>> X in any(Y, Z)
>
> It also doesn't have the desired laziness, unless we special case *any* in the interpreter, or provide a more generic
> mechanism for lazy parameters without writing *lambda: *everywhere
Well, currently any() and all() return True/False.
To overload like this would require returning an object with a __contains__ like Greg's either() (which is lazy), and a
__bool__ that does what any() and all() currently do.
I can see it being confusing, and it also doesn't get the chained comparisons like "or in" and friends do.
--
~Ethan~
More information about the Python-ideas
mailing list