Here is an example of what I want to do
import mainmodule
output=dir(mainmodule)
output
['module1'
'module2'
...
]
dir(module1.module2)
['class1',
'class2',
...
]
Now assume that I want to write a recursive function that will go like this:
def printstructure(mod)
output=dir(mod)
for i in output:
print (i)
printstructure(mod+'.'+i) #trying to concatenate here to obtain module1.module2
The above is going to fail because module is an object (type(mod) is module and i is a string
The question is how do I get the child object (reference to it) when I know its name. Sorry if the question is naive I am learning OOP