【发布时间】:2023-02-09 11:04:08
【问题描述】:
# utils.py
class Foo:
def __init__():
print(__file__)
# mod.py
from utils import Foo
foo = Foo()
# This prints /absoulte/utils.py
# the expected output is /absoulte/mod.py
是否可以使用当前文件信息而不是在不传递参数的情况下定义导入类Foo 初始化?
【问题讨论】:
标签: python python-3.x