a, b = b, a + b
I chose this coding style from Building Skills in Python. Based on PHP and Obj-C, this destination type with multiple variables is not available (at least not as I saw). But it seems more logical to me. After all, why should I assign 'a' to a holding variable before replacing it.
The question is, what is the pythonic coding style?
Here is an example Fibonacci program:
a, b = 1, 2
output = str(a)
while b<=100:
output = output + " " + str(b)
a, b = b, a + b
print output
And, what is the best way you found to help you write more python code?
source
share