On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2014-03-30 10:17, Chris Angelico wrote: >> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase <t...@thechases.com> >> wrote: >>> Though am I correct that your iteration tests for equality, while >>> mine tests for identity? Also, my version bails early in the >>> event quitting early is possible. That's particularly useful in >>> the case of doing something like >>> >>> if all(x() is None for x in [func1, func2, func3, costly_func]): > ^^^ >>> do_something() >> >> Presumably you mean to actually call those functions, as checking >> the identity of a costly function is still cheap :) > > Which is what I do...calling only those necessary until the all/any > condition has been met. :-) > > If you create the list of things to iterate over by calling them as > you create the list, then you don't save much of anything. If you > only call until one of them breaks the any/all construct, you save > all the subsequent function calls.
*facepalm* Yep, you do indeed. My bad! Take no notice of the man behind the curtain... ChrisA -- https://mail.python.org/mailman/listinfo/python-list