Answers for "python iterate over instances of class"

0

python iterate over instances of class

class IterRegistry(type):
    def __iter__(cls):
        return iter(cls._registry)

class Person(object):
    __metaclass__ = IterRegistry
    _registry = []

    def __init__(self, name):
        self._registry.append(self)
        self.name = name
Posted by: Guest on March-14-2020

Code answers related to "python iterate over instances of class"

Python Answers by Framework

Browse Popular Code Answers by Language