gpt4 book ai didi

python - 覆盖导入,显示导入模块的模块名称

转载 作者:太空宇宙 更新时间:2023-11-03 12:09:27 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
know filename:line_no where an import to my_module was made

我想找出哪些模块正在导入我的示例模块“foo”:

foo.py

# pseudocode, this should be triggered when "foo" is imported
on_import():
print "foo is imported by module X"

酒吧.py

# this should print "foo is imported by module bar"
import foo

我怎样才能实现这个行为?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com