title: Custom comparison functions for built-in types in Python
body: <p>I am using Python's built-in sets to hold objects of a class I have defined. For this class, I defined <code>__eq__</code>, <code>__ne__</code>, and <code>__hash__</code> so that I can compare objects by my custom comparison functions. That works just fine, until I find out that I actually need <em>two</em> sets of comparison functions, which will be used in different ways at different times in my code.</p>
  
  <p>I can't define two sets of <code>__eq__</code>, etc. methods in my class, and Python's built-in set type does not accept a comparator argument. I suppose I could go write a wrapper class around set, but that seems like a lot more work than necessary.</p>
  
  <p>Is there any easier solution to this than writing my own set class?</p>