On 2014-03-29 18:41, Roy Smith wrote: > On Mar 29, 2014, at 6:36 PM, Tim Chase wrote: > > > And for cases where you have more than one or two things to test > > for None-itude, you could use > > > > if all(x is None for x in [a, b, c, d]): > > do_something_if_theyre_all_None() > > I might have written that as: > > if set([a, b, c, d]) == set(None) > > That's even clearer if you happen to already have the items in an > iterable: > > if set(conditions) == set(None)
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() -tkc -- https://mail.python.org/mailman/listinfo/python-list