How to pass a tuple return to a method that takes two arguments?

Hi all,

If have a dataclass like

@dataclass
Position:
    x: float
    y: float

and also have function the transforms x and y like new_x, new,y = Transform(x,y)
but instead of doing
new_x, new_y = Transform(x,y)
new_pos=Position(new_x, new_y)

I wanted to do something like
new_pos=Position(Transform(x,y))
but this throws an error missing 1 required positional argument: 'y'

Here you want argument unpacking: new_pos = Position(*Transform(x, y))

2 Likes

Thanks @zware !