def Recursion(): def Refactor(): N = (yield) print( N ); if N == 0: yield 0 r = Refactor() next( r ) x = r.send( N - 1 ) print( x ); yield x N = (yield) print( N ); r = Refactor() next( r ) print( r.send( N - 1 ) ) c = Recursion() next( c ) try: c.send( 5 ) except StopIteration: print( "stop" ) # Local Variables: # # tab-width: 4 # # compile-command: "python3.5 Refactor.py" # # End: #