Paul Rubin <http://phr...@nospam.invalid> writes:
> Tim Chase <python.l...@tim.thechases.com> writes: >> > Return True if all elements of the iterable are >> > true. ... >> Then I'd say the comment is misleading. An empty list has no item >> that is true (or false), yet it returns true. > > The comment is correct. "All the items of the iterable are true" > means EXACTLY the same thing as "there are no items of the iterable > that are false". The empty list has no false items. Therefore > all(empty_list) = True is the correct behavior. > > > Another possible implementation: > > import operator,itertools > def all(xs): > return reduce(operator.and_, itertools.imap(bool, xs), True) A contest! My entry: def all(iterable): return not sum(not x for x in iterable) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list