Re: [Tutor] Understanding code line

2014-03-27 Thread Emile van Sebille
On 3/21/2014 3:40 PM, Steven D'Aprano wrote: a = b This assigns the value to b. So if b was 4, now a is also 4. Steven means 'assigns the value to a' here. For anyone looking down the line... ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Understanding code line

2014-03-22 Thread spir
On 03/21/2014 06:14 PM, Gary wrote: Pythonists I am trying to understand the difference between a = b b = a + b and a,b = b, a+ b When used in my Fibonacci code the former generates 0,1,2,4,8,16,32 and the later Generates 0,1,1,2,3,5,8,13,21,34,55,89. The second is the sequence I want,

[Tutor] Understanding code line

2014-03-21 Thread Gary
Pythonists I am trying to understand the difference between a = b b = a + b and a,b = b, a+ b When used in my Fibonacci code the former generates 0,1,2,4,8,16,32 and the later Generates 0,1,1,2,3,5,8,13,21,34,55,89. The second is the sequence I want, but I would Like to understand the

Re: [Tutor] Understanding code line

2014-03-21 Thread Joel Goldstick
On Mar 21, 2014 1:16 PM, Gary gwengst...@yahoo.com wrote: Pythonists I am trying to understand the difference between a = b You have overwitten a b = a + b and a,b = b, a+ b This one evaluates the right side first, then assigns the result to a and b When used in my Fibonacci code the

Re: [Tutor] Understanding code line

2014-03-21 Thread Alan Gauld
On 21/03/14 17:14, Gary wrote: Pythonists I am trying to understand the difference between a = b b = a + b This does exactly what it says. It first makes a and b identical then makes b equal their sum, that is, b+b and a,b = b, a+ b The second form is not always available in

Re: [Tutor] Understanding code line

2014-03-21 Thread Ben Finney
Gary gwengst...@yahoo.com writes: Pythonists I am trying to understand the difference between a = b Retrieves the value referenced by ‘b’, then binds the name ‘a’ to the value. b = a + b Evaluates the expression ‘a + b’, then binds the name ‘b’ to the result. and a,b = b, a+ b

Re: [Tutor] Understanding code line

2014-03-21 Thread Steven D'Aprano
On Fri, Mar 21, 2014 at 01:14:22PM -0400, Gary wrote: Pythonists I am trying to understand the difference between a = b b = a + b and a,b = b, a+ b Try to evaluate the code in your head, as if you were the Python interpreter. Starting with the first version: a = b This