Skip to content

Instantly share code, notes, and snippets.

@ask
Created May 15, 2009 09:54
Show Gist options
  • Save ask/112148 to your computer and use it in GitHub Desktop.
Save ask/112148 to your computer and use it in GitHub Desktop.
def partial_cls(name, cls, *args, **kwargs):
def constructor(self, *moreargs, **morekwargs):
super(self.__class__, self).__init__(
*(args+moreargs), **dict(kwargs, **morekwargs))
constructor.__doc__ = cls.__init__.__doc__
constructor.func_name = cls.__init__.__name__
dict_ = {"__init__": constructor}
return type(name, (cls, ), dict_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment