News for hackers. Stuff that matters.
Re:Dive Into Python 3 (online book) by enterneo on Tuesday August 09, 2011 @04:32AM (#2863365)
in fact to reiterate have a look at the awesome fibonacci example showing power of generators [1]:

    def fibonacci(max):
        a, b = 0, 1       
        while a < max:
            yield a       
            a, b = b, a+b
To run the function do:

    >>> for n in fibonacci(1000): 
    ...     print n,              
    0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
[1] http://diveintopython.org/dynamic_functions/stage6.html

There are no comments on this comment yet.