#!/usr/bin/env python3
# -- coding: utf-8 --
# @Date : 2018-07-12 22:59:07
# @Author : Simon (simon.xie@codewalker.meg)
# @Link : http://www.codewalker.me
# @Version : 1.0.0
class Fib:
def __init__(self):
self.prev = 0
self.curr = 1
def __iter__(self):
return self
def __next__(self):
self.curr, self.prev = self.prev + self.curr, self.curr
return self.curr
def main():
fib = Fib()
fib_list = []
for _ in range(10):
fib_list.append(next(fib))
print(fib_list)
if __name__ == “__main__“:
main()