> you can use them as fully anonymous functions.
A lambda can only contain a single expression, by "full anonymous function" I'm guessing hexane360 means multiple statements. You can't put a for loop or a context manager in a lambda for instance.
A lambda can only contain a single expression, by "full anonymous function" I'm guessing hexane360 means multiple statements. You can't put a for loop or a context manager in a lambda for instance.
http://rosettacode.org/wiki/Runge-Kutta_method#using_lambda
It does not look as bad as one might expect, though the nesting of parenthesis makes things messy.
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)
but you can't do that itself as a lambda.
And I consider modifying the ast cheating :PNo disagreement, really depends whether you're a "rules" or "spirit" kind of person though.