【发布时间】:2019-12-03 03:40:03
【问题描述】:
给定同一数据类的两个实例,我如何使用第二个的值就地更新第一个?
即
@dataclass
class Foo:
a: str
b: int
f1 = Foo("foo", 1)
f2 = Foo("bar", 2)
# Update in place, so that f1.a == f2.a, f1.b == f2.b and so on
注意:我不想简单地设置f1 = f2;我想更新f1。
【问题讨论】: