Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class make_fibonacci(object):
- def __init__(self):
- self.current = 0
- self._next = 1
- def __call__(self):
- fib = self.current
- self.current, self._next = self._next, self.current + self._next
- return fib
- iterator = make_fibonacci()
- for i in range(10):
- num = iterator()
- print num
Add Comment
Please, Sign In to add comment