Should any() and all() take a key= argument?

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Apr 1 06:12:25 EST 2006


Em Sáb, 2006-04-01 às 20:44 +1000, Steven D'Aprano escreveu:
> Here's another way of doing it:
> 
> lst = [2, 4, 42]
> any(map(lambda x: x==42, lst))

In fact, as we're talking about Python 2.5 anyway, it would be better
not to waste memory and use:

any(x == 42 for x in lst)

-- 
Felipe.




More information about the Python-list mailing list