Steven D'Aprano <st...@remove-this-cybersource.com.au> writes: > (2) Why assume that a, b and c are sequences with a fast __len__ method? > They might be (say) linked lists that take O(N) to calculate the length, > or binary trees that don't even have a length, but can be iterated over.
Why assume they have a bool method? Or a __or__ operator? > for seq in [a,b,c]: > if len(seq) > 0: > for x in seq: > do_something_with(x) > break Eh. for seq in [a,b,c]: if sum(1 for x in imap(do_something_with, seq)) > 0: break -- http://mail.python.org/mailman/listinfo/python-list