Re:Coconut – Pythonic functional programming language
by masklinn on Thursday June 23, 2016 @01:35PM
(#11962870)
Well you might be able to if you add a bunch of named function combinators wrapping these, but definitely not with only lambdas, unless you define your combinators using `ast`, which I think would let you define statements via expressions.
Re:Coconut – Pythonic functional programming language
by AnkhMorporkian on Thursday June 23, 2016 @03:18PM
(#11963663)
That's an awful lot of effort to go to to avoid naming a function.
Re:Coconut – Pythonic functional programming language
by zardeh on Friday June 24, 2016 @12:58PM
(#11971444)
Well sure, you could do something like
def apply_ctx(ctx, func, *func_args, **func_kwargs):
with ctx as __ctx:
func(*func_args, **func_kwargs, ctx=__ctx)
but you can't do that itself as a lambda.
And I consider modifying the ast cheating :P
You can't get context managers or exception handling (although you can raise exceptions) into lambdas, I've tried.