File: LP6E/Chapter30/squares_yield_manual.py

import squares_yield                      # Reuse prior example's __init__

class Squares(squares_yield.Squares):     # Non __iter__ equivalent 
    def gen(self):
        for value in range(self.start, self.stop + 1):
            yield value ** 2



[Home page] Books Code Blog Python Author Train Find ©M.Lutz