1class MyObject():
2
3 def __init__(self):
4 self.a = 1
5 self.b = 2
6 self.c = 3
7
8 def __iter__(self):
9 yield 'a', self.a
10 yield 'b', self.b
11 yield 'c', self.c
12
13dict(MyObject())
14
15>>>
16{
17 'a': 1,
18 'b': 2,
19 'c': 3
20}