Class factory in Python
I think using a function is fine. The more interesting question is how do you determine which registrar to load? One option is to have an abstract base Registrar class which concrete implementations subclass, then iterate over its __subclasses__() calling an is_registrar_for() class method: class Registrar(object): def __init__(self, domain): self.domain = domain class RegistrarA(Registrar): @classmethod … Read more