2013-01-01から1ヶ月間の記事一覧
class Counter: def __init__(self, max): self.max = max def __iter__(self): self.n = 0 return self def next(self): if self.n > self.max - 1: raise StopIteration self.n += 1 return self.n - 1 if __name__ == '__main__': for i in Counter(5): p…