Tag archive for: class reflection

How to look for classes defined in Python 3 files dynamically

There are times when we need to write Python codes that extends the functionality of others, especially when we are writing a framework that allows for custom extension. To allow my Python program to be extended by others via the template design pattern, the first exploration task that I did was to find out how to dynamically look for classes defined in arbitrary Python files.

This post documents a way to look for classes defined in Python 3 files dynamically.