title: python "in" operator reflected magic method
body: <p><code>|</code> operator has two magic methods, normal and reflected. </p>
  
  <pre><code># object + other
  __or__(self, other)
      # Implements bitwise or using the | operator.
  
  # other + object
  __ror__(self, other)
      # Implements reflected bitwise or using the | operator.
  </code></pre>
  
  <p><code>in</code> operator only has one magic method.</p>
  
  <pre><code># item in object
  __contains__(self, item)
      # __contains__ defines behavior for membership tests using in and not in.
  </code></pre>
  
  <hr>
  
  <p><strong>How can I implement <code>in</code> operator reflected magic method?</strong></p>
  
  <pre><code># object in sequence
  __rcontains__(self, sequence):
      # defines behavior for self in or not in sequence
  </code></pre>
  
  <p>It will be useful when you want to implement sql conditions</p>
  
  <pre><code>class Field(object):
      def __lt__(self, other):
          return '&lt;', self._value, other
  
  Model.objects.filter(Field('a') &gt; 1)
  Model.objects.filter(Field('a') in [1, 2, 3, 4])
  </code></pre>