Python: Find all subclasses of a class


I would have thought there was some trickery or magic to this, or some sort of hidden Django function/signal to use.

But NOPE! With Python, it's a one line wonder!

# Get all subclasses for class

That's it! Best part is there's no special imports to do, "type" is already a built-in, so it's available anywhere at any time.

High 5's all round, fuck yeah!

Related Posts


Post a Comment

Leave your thoughts ...
If you are having trouble with copy/pasting in comments, you need to sign in or click 'Preview'. For more information about this Firefox bug, see here.

Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog