I am trying to convert a list of return values to a list of functions that return these values.
lst = [1, 2]
funcs = [lambda: x for x in lst]
this is equivalent to:
x = 2
funcs = [lambda: x, lambda: x]
but I am trying to get:
funcs = [lambda: 1, lambda 2]
This question explains why this is happening, but doesn't provide a way to do it.
Is there any way to achieve this?