Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumPythondataclassesSingle-choice MCQ

Two dataclass instances are created with the same scalar argument. After mutating the list of the first via default_factory, what does the comparison print?

from dataclasses import dataclass, field @dataclass class A: x: int y: list = field(default_factory=list) a = A(1) b = A(1) a.y.append(9) print(b.y, a == b)