I\'d like to compare multiple objects and return True only if all objects are not equal among themselves. I tried using the code below, but it doesn\'t work. If
@Michael Hoffman's answer is good if the objects are all hashable. If not, you can use itertools.combinations:
>>> all(a != b for a, b in itertools.combinations(['a', 'b', 'c', 'd', 'a'], 2))
False
>>> all(a != b for a, b in itertools.combinations(['a', 'b', 'c', 'd'], 2))
True