I'm doing a complicated hack in Python, it's a problem when you mix for+lambda+*args (don't do this at home kids), the boring details can be omited, the unique solution I found to resolve the problem is to pass the lambda object into the self lambda in this way:
for ...
lambda x=x, *y: foo(x, y, <selflambda>)
It's possible?, thanks a lot.
You are looking for a fixed-point combinator, like the Z combinator, for which Wikipedia gives this Python implementation:
Z = lambda f: (lambda x: f(lambda *args: x(x)(*args)))(lambda x: f(lambda *args: x(x)(*args)))
Z takes one argument, a function describing the function you want, and builds and returns that function.
The function you're looking to build is:
Z(lambda f: lambda x=x, *y: foo(x, y, f))
While your question is genuinely weird, try something like:
>>> import functools
>>> f = lambda selflambda, x=x, *y: foo(x, y, selflambda)
>>> f = functools.partial(f, f)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With