Making this reduce() Fibonacci generator better I've recently discovered how cool reduce() could be and I want to do this:

&gt;&gt;&gt; a = [1, 1] + [0] * 11
&gt;&gt;&gt; count = 1
&gt;&gt;&gt; def fib(x,n):
...     global count
...     r = x + n
...     if count &lt; len(a) - 1: a[count+1] = r
...     count += 1
...     return r
&gt;&gt;&gt;
&gt;&gt;&gt; reduce(fib,a,1)
610
&gt;&gt;&gt; a
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]


But this just looks so messy and almost defeats the purpose of the last line:

reduce(fib,a,1)


What would be a better way to use Python to make a Fibonacci number with reduce()?
A reduce (that's it, a fold) is not exactly the abstraction for the task (what input collection are you going to fold here?). Anyway, you can cheat a little bit and fold the indexes even if you don't really use them within the folding function. This works for Python 2.x:

def next_fib((x, y), n):
    return (y, x + y)

reduce(next_fib, xrange(5), (1, 1))[0]
#=&gt; 8