Skip to content

Tag: introspection

Iterate the classes defined in a module imported dynamically

I have a module from a child package that is imported dynamically; how can I iterate over the classes that it contains? I have been importing the module and listing the names like this: This only prints module attributes and not the class types that the module defines: It seems that my classes are not in the …

How can I get the name of an object?

Suppose I have code like: How can I get the name of each object in Python? That is to say: what could I write instead of name in this code, so that the loop will show handling object x and then handling object y and handling object z? In my actual code, I have a dict of functions that I