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'