Why doesn't Python have a "__req__" (reflected equality) method?
Why doesn't Python have a "__req__" (reflected equality) method? Question: I have a little helper class: class AnyOf(object): def __init__(self, *args): self.elements = args def __eq__(self, other): return other in self.elements This lets me do sweet magic like: >>> arr = np.array([1,2,3,4,5]) >>> arr == AnyOf(2,3) np.array([False, True, True, False, False]) without having to use …