On Mon, 2010-03-22 at 14:45 +0000, kj wrote:
> I have a list of items L, and a test function is_invalid that checks
> the validity of each item.  To check that there are no invalid
> items in L, I could check the value of any(map(is_invalid, L)).
> But this approach is suboptimal in the sense that, no matter what
> L is, is_invalid will be executed for all elements of L,

any( is_invalid(a) for a in L )

... generator expression will be lazily computed.

Tim

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to