@dataclass class D: x: List = [] def add(self, element): self.x += element