class ObjectPool: def __init__(self, selector, constructor): self.selector = selector self.constructor = constructor self.pool = [] def load_from_db(self, cur): cur.execute(f"SELECT * FROM {self.selector};") self.pool = [self.constructor().init_from_data(i) for i in cur] return self