@Alan
@Dave
@Dominik
thank you all so much for the elaborate explanations! It's really
simple and crystal clear now, the most difficult part was actually to
detect and overcome my own misconceptions. Once I did that, the rest
was really easy. Kind of a valuable learning for the future ;-)
Instead
On 24/11/13 13:05, Rafael Knuth wrote:
"a" and "b" on the left side are unchangable tuples and they simply get
unpacked on the right side.
Be careful about terminology here. a,b is a single tuple with two
values. But a and b are variables not tuples.
Tuples are collections of (one or more)
Now I got it, thanks :-)
a, b = b, b + a
... I was was wrongly assuming that "a" and "b" on the left side "talk" to
each other and that "a" tells "b" something like: "Hey 'b' ... I just
assigned another value to you, make sure you execute it." But "a" and "b"
don't talk to each other. Each of th
On Sun, 24 Nov 2013 11:24:43 +0100, Rafael Knuth
wrote:
a, b = b, a +b
a = b = 1
b = a + b = 1 + 1 = 2
I suggest you play with the statement a bit. Print out both values
each time through the loop.
The expression b, a+b produces a tuple. The left side a, b *unpacks*
that tuple into
Hi,
> a, b = b, a +b
> a = b = 1
> b = a + b = 1 + 1 = 2
Your issue is that you interpret the assignment wrong. You seem to think
that it assigns b to a and THEN a+b to b, which is not the case. The
right side of the assignment creates a tuple, and the left side unpacks
it. It is the same as
(key-len(self.fibsseq)+1):
self.fibsseq.append(self.fibsseq[-1] + self.fibsseq[-2])
return self.fibsseq[key]
Date: Thu, 3 Jul 2008 12:59:39 +1200
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [Tutor] Fibonacci series(perhaps slightly off topic)
CC: tu
]
> Date: Thu, 3 Jul 2008 12:59:39 +1200
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: [Tutor] Fibonacci series(perhaps slightly off topic)
> CC: tutor@python.org
>
> On 03/07/2008, Emil wrote:
>> I have created a cl
On 03/07/2008, Emil <[EMAIL PROTECTED]> wrote:
> I have created a class called Fibs which allow you to access a specific
> number in the
> Fibonacci series(http://en.wikipedia.org/wiki/Fibonacci_number) But it seems
> to me that it
> is a bit inefficient, any suggestions on how to make it more e