You can't get context managers or exception handling (although you can raise exceptions) into lambdas, I've tried.
def apply_ctx(ctx, func, *func_args, **func_kwargs): with ctx as __ctx: func(*func_args, **func_kwargs, ctx=__ctx)
No disagreement, really depends whether you're a "rules" or "spirit" kind of person though.
You can't get context managers or exception handling (although you can raise exceptions) into lambdas, I've tried.