Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo():
- a = 1
- b = 2
- c = 42
- d = ['hello', 'world']
- def __iter__(self):
- yield self.a
- yield self.b
- yield self.c
- yield from self.d
- f = Foo()
- for x in f:
- print(x)
- # Should print the following:
- # 1
- # 2
- # 42
- # 'hello'
- # 'world'
Advertisement
Add Comment
Please, Sign In to add comment