I want to instantiate a regular class Motion using the dataclass Points, and the regular class is supposed to have four parameters namely self, x, y, and z. However, when I pass the dataclass to the regular class,and run the test method, I get the error:
Motion.__init__() missing 2 required positional arguments: 'y' and 'z'.
How do I fix this?
Source code:
from dataclasses import dataclass@dataclass class Points: x: int y: int z: intclass Motion: def __init__(self, x:int, y:int, z:int): self.x = x self.y = y self.z = z def test(self): print(self.x, self.y, self.z)result = Motion(Points(1,2,3))result.test()