Created
February 14, 2011 18:58
-
-
Save thanos/826349 to your computer and use it in GitHub Desktop.
Returns a list of all the sublasses and returns them. A nice way of implementing plug-ins.
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 discover(root, classes=[]): | |
| """ | |
| Returns a list of all the sublasses and returns them. A nice way of implementing plug-ins. | |
| """ | |
| for cls in root.__subclasses__(): | |
| classes.append(cls) | |
| discover(cls, classes) | |
| return classes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment