On Feb 25, 10:25 pm, [EMAIL PROTECTED] wrote: > Paul Rubin: > > > def ggenfib(): > > a,b = 1,2 > > while True: > > yield a > > a,b = b, a=b > > Your version is the nice basic generator version (the last line > contains a +, I presume), but I like this other version too: > > def xfibonacci(): > a = b = 1 > yield a > yield b > while True: > a = a + b > yield a > b = b + a > yield b > > It's a bit faster, longer, and I find it a bit more readable.
In this case why not: def xfib(a=1, b=1): while True: yield a a += b yield b b += a -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list