【发布时间】:2017-06-08 16:21:56
【问题描述】:
是否可以获取包含该类的文件的名称?变量exporter是下面的一个类。
def main(exporter):
v = exporter
print v # <__main__.Vudu object at 0x106ea5210>
# The class is "Vudu" and the filename that contains that class
# is called vudu_exporter. How would I get "vudu_exporter" ?
更新:以下方法用于获取包含该类的脚本的名称:
script_name = os.path.basename(inspect.getfile(v.__class__))
【问题讨论】:
-
vudo.vudu_exporter.__file__应该包含它的名字。 -
什么课?您还没有向我们展示任何课程。
标签: python