Use *params
calls to the viewport function instead:
coordinates = lambda_mapping[key](argument)
viewport_set(*coordinates)
This applies the coordinates
tuple as separate arguments to the viewport_set()
function.
Demo:
>>> def foo(x, y):
... print(x, y)
...
>>> coordinates = (42, 38)
>>> foo(*coordinates)
42 38
Now you don't have to adjust the viewport function to take tuples as well as separate arguments.
The other alternative is to make the second coordinate a keyword argument:
def viewport_set(x, y=None):
if y is None:
# assume x is a sequence of two coordinates instead
x, y = x