def Fibonacci(): fn = 0; fn1 = fn; yield fn # suspend fn = 1; fn2 = fn1; fn1 = fn; yield fn while True: fn = fn1 + fn2; fn2 = fn1; fn1 = fn; yield fn f1 = Fibonacci() f2 = Fibonacci() for i in range( 10 ): print( next( f1 ), next( f2 ) ) # resume # Local Variables: # # tab-width: 4 # # compile-command: "python3.5 Fib.py" # # End: #