Skip to content

Instantly share code, notes, and snippets.

@ramnes
Created November 13, 2014 17:16
Show Gist options
  • Save ramnes/6131c2830167cb5be17a to your computer and use it in GitHub Desktop.
Save ramnes/6131c2830167cb5be17a to your computer and use it in GitHub Desktop.
class Factory(object):
model = object
def __init__(self):
self._objs = {}
def create(self, name):
self._objs[name] = type(name, self.model.__bases__, dict(self.model.__dict__))
return self._objs[name]
def get(self, name):
return self._objs.get(name)
def new(self, name):
return self._objs[name]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment