Where is module being imported from?

前端 未结 8 1404
余生分开走
余生分开走 2020-12-07 19:57

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         


        
8条回答
  •  没有蜡笔的小新
    2020-12-07 20:28

    Try my_module.__file__ to find out where it is from. If you get an AttributeError, it is probably not a Python source (.py) file.

提交回复
热议问题