Python: determining whether any item in sequence is equal to any other

Viewed 559

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 obj1 and obj3 are equal and obj2 and obj3 are not equal, the result is True.

obj1 != obj2 != obj3

I have more than 3 objects to compare. Using the code below is out of question:

all([obj1 != obj2, obj1 != obj3, obj2 != obj3])
5 Answers
Related