title: How is the __contains__ method of the list class in Python implemented?
body: <p>Suppose I define the following variables:</p>
  
  <pre><code>mode = "access"
  allowed_modes = ["access", "read", "write"]
  </code></pre>
  
  <p>I currently have a type checking statement which is</p>
  
  <pre><code>assert any(mode == allowed_mode for allowed_mode in allowed_modes)
  </code></pre>
  
  <p>However, it seems that I can replace this simply with</p>
  
  <pre><code>assert mode in allowed_modes
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/users/298479/thiefmaster">ThiefMaster</a>'s answer in <a href="https://stackoverflow.com/questions/10210233/python-list-class-contains-method-functionality">Python List Class __contains__ Method Functionality</a>, these two should be equivalent. Is this indeed the case? And how could I easily verify this by looking up Python's source code?</p>