For imported module, is it possible to get the importing module (name)? I'm wondering if inspect can achieve it or not~
It sounds like you solved your own problem: use the inspect module. I'd traverse up the stack until I found a frame where the current function was not __import__. But I bet if you told people why you want to do this, they'd tell you not to.
Even if you got it to work, this is probably less useful than you think since subsequent imports only copy the existing reference instead of executing the module again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With