`itertools.all_equal`

It is.

The grouping is done by checking for equality.

And quoting Raymond about all_equal (or its old recipe version, not sure):

Which is perfectly fine and normal. Do you also dislike all’s equivalent code

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

because it’s supposed to check whether all elements are true, but instead checks whether they’re "not* true and doesn’t even check all elements, instead using the first not true element to “prove by contradiction that all the elements are not true”?

2 Likes