title: How do Python's any and all functions work?
body: <p>I'm trying to understand how the <code>any()</code> and <code>all()</code> Python built-in functions work.</p>
  <p>I'm trying to compare the tuples so that if any value is different then it will return <code>True</code> and if they are all the same it will return <code>False</code>. How are they working in this case to return [False, False, False]?</p>
  <p><code>d</code> is a <code>defaultdict(list)</code>.</p>
  <pre><code>print d['Drd2']
  # [[1, 5, 0], [1, 6, 0]]
  print list(zip(*d['Drd2']))
  # [(1, 1), (5, 6), (0, 0)]
  print [any(x) and not all(x) for x in zip(*d['Drd2'])]
  # [False, False, False]
  </code></pre>
  <p>To my knowledge, this should output</p>
  <pre><code># [False, True, False]
  </code></pre>
  <p>since (1,1) are the same, (5,6) are different, and (0,0) are the same.</p>
  <p><strong>Why is it evaluating to False for all tuples?</strong></p>
  <hr />
  <p><sub>See <a href="https://stackoverflow.com/questions/1342601">Pythonic way of checking if a condition holds for any element of a list</a> for practical usage of <code>any</code>.</sub></p>