[Tutor] Understanding code line
Alan Gauld
alan.gauld at btinternet.com
Fri Mar 21 22:14:12 CET 2014
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 programming languages so R
may not support it directly.
The more general version would be:
temp = a
a = b
b = temp + b
> Like to understand the second code sequence better so I
> can write the code in R and Scilab as well as python.
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list