Bill Janssen wrote: > Yeah, but you can't do more complicated expressions that way, like > > any(lambda x: x[3] == "thiskey")
Not /quite/ sure what this is intended to mean, but most likely, you meant 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 don't believe that adds expressiveness: you can always formulate this with a generator expression - apparently, those are of the "read-only" nature, i.e. difficult to formulate (assuming you have no difficulties to read above term). > I suppose > > (len([x for x in SEQ if PRED(x)]) > 0) > > will suffice for now. Obvious enough, Martin? It's simpler written as any(PRED(x) for x in SEQ) or any(True for x in SEQ if PRED(x)) if you want Using any() has the advantage over len() that the any() code stops at the first value that becomes true, whereas the len code ill compute them all. Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com