【发布时间】:2022-10-02 02:50:43
【问题描述】:
所以我有一个这样的module.py:
import dataclass
@dataclass
class A:
x: int
y: int
def big_method(self):
do_big_stuff(x,y)
LIST_OF_A = [ A(2,3), B(4,5) ]
为什么当我在我的 script.py 中时
from module import A
script.py 实际运行并实例化了 LIST_OF_A ?我修复它的唯一方法是将文件与类定义和 LIST_OF_A 分开。有没有办法将两者结合在一个module.py中?
标签: python python-3.x