Beginner's assignment question

Colin J. Williams fn681 at ncf.ca
Sat Mar 1 16:46:45 CET 2008


Schizoid Man wrote:
> As in variable assignment, not homework assignment! :)
> 
> I understand the first line but not the second of the following code:
> 
> a, b = 0, 1
> a, b = b, a + b
> 
> In the first line a is assigned 0 and b is assigned 1 simultaneously.
> 
> However what is the sequence of operation in the second statement? I;m 
> confused due to the inter-dependence of the variables.
In the second line a now points to the 
value 1 and b points to 1 (the sum of 
zero and one) in a unitary operation 
(i.e. in turn, but effectively 
simultaneously).

You might disassemble the code to see 
the sequence.

Colin W.



More information about the Python-list mailing list