Assuming I have two Python modules and path_b is in the import path:
# file: path_b/my_module.py print \"I was imported from ???\" #file: path_a/app.py impo
Also, if you have a function/class f from a module m you can get the path of the module using the module inspect
f
m
inspect
import inspect from m import f print inspect.getmodule(f)