[Tutor] (no subject)

Jerry Hill malaclypse2 at gmail.com
Fri Mar 21 21:57:32 CET 2014


On Fri, Mar 21, 2014 at 3:25 PM, Gary Engstrom <gwengstrom at yahoo.com> wrote:
> I am trying to understand function fibc code line a,b = b, a + b and would
> like to see it written line by line
> without combining multiply assignment. If possible. I sort of follow the
> right to left evaluation of the other code.

Sure.  a,b = b, a+b is equivalent to:

new_a = b
new_b = a + b
a = new_a
b = new_b
del new_a
del new_b

That is, we first evaluate everything on the right hand side of the
equals sign, then assign those values to a and b.  Then we get rid of
the temporary variables, since the original statement didn't leave any
temporary variable floating around.

-- 
Jerry


More information about the Tutor mailing list