[Python-Dev] Any reason that any()/all() do not take apredicateargument?

Raymond Hettinger raymond.hettinger at verizon.net
Sun Apr 16 05:26:43 CEST 2006


[Bill Janssen]
> Yeah, but you can't do more complicated expressions that way, like
>> any(lambda x: x[3] == "thiskey")

You're not making any sense. The sequence argument is not listed and the lambda 
is unnecessary. Try this instead:
 any(x[3] == 'thiskey' for x in seq)
> I think it makes a lot of sense for any and all to take optional
> predicate function arguments.

I think you don't understand what you already have to work with in Py2.5a -- a 
boolean expression in a genexp should always suffice -- no separate lambda based 
predicate function is ever required.
Raymond


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /