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 __dict__ unless the
Tag: introspection
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
How to get method parameter names?
Given that a function a_method has been defined like Starting from a_method itself, how can I get the argument names – for example, as a tuple of strings, like (“arg1”, “arg2”)? Answer Take a look at the inspect module – this will do the inspection of the various code object properties for you. The other results are the name of