[英]How to print python module hierarchy?
I have a file which is dynamically loaded. 我有一个动态加载的文件。 Because of the dynamic loading, I have no idea what its module path is, and all of my best guesses (per the filesystem structure) have failed so far.
由于动态加载,我不知道它的模块路径是什么,到目前为止(根据文件系统结构)我所有的最佳猜测都失败了。
(Python 2.6) (Python 2.6)
If you're able to import that module runtime anyways you have the access to __file__
attribute of it, which will give you the exact location of your module. 如果仍然能够导入该模块运行时,则可以访问其
__file__
属性,这将为您提供模块的确切位置。
for example: 例如:
In [1]: import os
In [2]: print os.path.dirname(os.__file__)
/usr/lib/python2.7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.