title: How to override comparison for floats in a list in Python?
body: <p>I am trying to check two normal vectors for equality. My normal vector is represented as a three-element list, one element for each spacial coordinate (X, Y, and Z). All coordinates are rounded to 4 decimal places. I want to check if two surfaces have the same normal, so I have something like the following:</p>
  
  <pre><code>if (surface1.normal in [surface2.normal, self.NegatedNormal(surface2.normal)]):
      # do stuff here
  </code></pre>
  
  <p>The problem is my normals look like this:</p>
  
  <pre><code>surface1.normal: [0.9947, 0.0155, 0.1015]
  surface2.normal: [0.9947, 0.0155, 0.1014]
  </code></pre>
  
  <p>Note that the z-coordinate is off by 0.0001. So is there a way I can override the equals operator to accept answers within 0.0001 from each other that is compatible  with comparisons in other data structures (like a list in my case)? I have a feeling I'd have to write my own __eq__ method but I'm not quite sure how I would do this. </p>
  
  <p>Also, if this is not the best course of action, is their a better way to compare two lists of floats within a given tolerance?</p>