1class IterRegistry(type):
2 def __iter__(cls):
3 return iter(cls._registry)
4
5class Person(object):
6 __metaclass__ = IterRegistry
7 _registry = []
8
9 def __init__(self, name):
10 self._registry.append(self)
11 self.name = name