I am trying to build a function
f(x, y, z)
where neither x nor y have any impact on the result. Nonetheless, they must be passed to the function, as the passing is done by a library. I would like to:
As I have gathered, using the underscore character for redundant return values from multiple-value-returning functions is common practice, e.g.
a, _, c, d, _, _ = return_six_things(),
however, trying
f = lambda _, _, z: some_operation(z)
crashes with the exception warning the author about using 'duplicate arguments' (two underscore characters).
Are there any other options?
P.S. to avoid the XY problem, the reason I want to use lambdas is to save a few source code characters. I would love to use them anyway, but declaring that "these parameters will not be used" is more important for me.
I'd use a double underscore (__
) for the second unused argument:
f = lambda _, __, z: some_operation(z)