Skip to content

Instantly share code, notes, and snippets.

@thanos
Created February 14, 2011 18:58
Show Gist options
  • Select an option

  • Save thanos/826349 to your computer and use it in GitHub Desktop.

Select an option

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.
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