title: How does the 'in' operator determine membership?
body: <p>How does the <code>in</code> operator work for Python? </p>
  
  <p>In the example below I have two namedtuples that are different objects, but the <code>in</code> operator evaluates to True for an array containing one of the objects.  </p>
  
  <p>Is <code>in</code> checking if the array contains the object, or does it check if any object in the array is equivalent? I tried searching for documentation but couldn't find anything specific, just simple examples.</p>
  
  <pre><code>In [3]: a = namedtuple('test', ['t'])                             
  
  In [6]: b = a(1)                      
  
  In [7]: c = a(1)                      
  
  In [8]: b is c                        
  Out[8]: False                         
  
  In [9]: id(b)                         
  Out[9]: 54740808                      
  
  In [10]: id(c)                        
  Out[10]: 88817352                     
  
  In [11]: c in [b]                     
  Out[11]: True                         
  
  In [12]: b in [c]                     
  Out[12]: True                         
  
  In [13]: c == b                       
  Out[13]: True           
  </code></pre>