Possible duplicate:
know file_name: line_no where the import was made in my_module
I want to know which modules import my sample module "foo":
foo.py
# pseudocode, this should be triggered when "foo" is imported on_import(): print "foo is imported by module X"
bar.py
# this should print "foo is imported by module bar" import foo
How can I implement this behavior?
source share