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
type.__subclasses__(Subscription)

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.

Cpv5G
High 5's all round, fuck yeah!

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