iterate through attributes of class python
L = [[getattr(self, attr), attr] for attr in dir(self) if not attr.startswith("__")]
iterate through attributes of class python
L = [[getattr(self, attr), attr] for attr in dir(self) if not attr.startswith("__")]
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us