title: Cannot implement __lt__ operator
body: <p>I have a class <code>Quantity</code> and I want to implement the <code>__lt__</code> operator to overload. I have implemented the method as shown below.</p>
  
  <pre><code>    def __lt__(self, other):
          if isinstance(other, Quantity):
              return other.value &lt; self.value
          if isinstance(other, numbers.Real):
              return self.value &lt; other
          raise NotImplemented
  </code></pre>
  
  <p>When I import it into the python console and try to execute it</p>
  
  <pre><code>&gt;&gt;&gt; Quantity(1.2) &gt; 1
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>AttributeError: 'int' object has no attribute 'number'
  </code></pre>
  
  <p>And if I try to execute it like this</p>
  
  <pre><code>&gt;&gt;&gt; Quantity(1.2) &lt; 1
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>TypeError: '&lt;' not supported between instances of 'Quantity' and 'int'
  </code></pre>
  
  <p>Does anyone know how can I implement the overload to work with <code>&lt;</code> and <code>&gt;</code>?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is the full class</p>
  
  <pre><code>class Quantity:
  
      def __init__(self, value):
          self.value = float(value)
  
      def __float__(self):
          return self.value
  
      def __repr__(self):
          return 'Quantity({})'.format(self.value)
  
      def __str__(self):
          return str(self.value)
  
  
     def __lt__(self, other):
          if isinstance(other, Quantity):
              return other.value &lt; self.value
          if isinstance(other, numbers.Real):
              return self.value &gt; other
          raise NotImplemented
  
      @property
      def value(self):
          return self._value
  
      @value.setter
      def value(self, value):
          value = round(value, 10)
          self._value = int(value * 1000) / 1000.0
  
  </code></pre>