4
可能重複:
know filename:line_no where an import to my_module was made覆蓋進口,模塊的顯示名稱導入模塊
我想找出哪些模塊導入我的樣本模塊「富」:
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
我該如何實現這種行爲?