title: How does Python's comma operator work during assignment?
body: <p>I was reading the assignment statements in the Python docs ( <a href="http://docs.python.org/reference/simple_stmts.html#assignment-statements" rel="nofollow noreferrer">http://docs.python.org/reference/simple_stmts.html#assignment-statements</a>).</p>
  <p>In that it is quoted that:</p>
  <blockquote>
  <p>If the target is a target list enclosed in parentheses or in square brackets: The object must be an iterable with the same number of items as there are targets in the target list, and its items are assigned, from left to right, to the corresponding targets.</p>
  </blockquote>
  <p>After reading it, I thought of writing a sample like this:</p>
  <pre><code>a = 5
  b = 4
  a, b = a + b, a
  print a, b
  </code></pre>
  <p>My assumption was that a and b both should have the value of 9.</p>
  <p>However, I am proven wrong. 'a' has the value of 9 and 'b' has the value of 5.</p>
  <p>Can some one help me understand this better? Why the older value of 'a' is assigned rather than the new one? As per the docs, a's value will be assigned first right? Am I missing something?</p>