Created
November 13, 2014 17:16
-
-
Save ramnes/6131c2830167cb5be17a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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