Created
September 21, 2011 13:02
-
-
Save jacob414/1231969 to your computer and use it in GitHub Desktop.
Subclass via function in Python
This file contains hidden or 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
def subclass(Cls, name=None): | |
class _(Cls):pass | |
_.__name__ = name or 'subclass' | |
return _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Handy when you want to create large amounts of simple permutations from a base class.