(expression, args, env=None)
return finner
Create an lambda function from a expression AST.

    Parameters
    ----------
    expression : ast.Expression
        The body of the lambda.
    args : List[str]
        A list of positional argument names
    env : Optional[Dict[str, Any]]
        Extra environment to capture in the lambda's closure.

    Returns
    -------
    func : types.FunctionType
Create an lambda function from a expression AST.
Create an lambda function from a expression AST .
def make_lambda(expression, args, env=None):
    # type: (ast.Expression, List[str], Dict[str, Any]) -> types.FunctionType
    """
    Create an lambda function from a expression AST.

    Parameters
    ----------
    expression : ast.Expression
        The body of the lambda.
    args : List[str]
        A list of positional argument names
    env : Optional[Dict[str, Any]]
        Extra environment to capture in the lambda's closure.

    Returns
    -------
    func : types.FunctionType
    """
    # lambda *{args}* : EXPRESSION
    lambda_ = ast.Lambda(
        args=ast.arguments(
            posonlyargs=[],
            args=[ast.arg(arg=arg, annotation=None) for arg in args],
            varargs=None,
            varargannotation=None,
            kwonlyargs=[],
            kwarg=None,
            kwargannotation=None,
            defaults=[],
            kw_defaults=[]),
        body=expression.body,
    )
    lambda_ = ast.copy_location(lambda_, expression.body)
    # lambda **{env}** : lambda *{args}*: EXPRESSION
    outer = ast.Lambda(
        args=ast.arguments(
            posonlyargs=[],
            args=[ast.arg(arg=name, annotation=None) for name in (env or {})],
            varargs=None,
            varargannotation=None,
            kwonlyargs=[],
            kwarg=None,
            kwargannotation=None,
            defaults=[],
            kw_defaults=[],
        ),
        body=lambda_,
    )
    exp = ast.Expression(body=outer, lineno=1, col_offset=0)
    ast.fix_missing_locations(exp)
    GLOBALS = __GLOBALS.copy()
    GLOBALS["__builtins__"] = {}
    # pylint: disable=eval-used
    fouter = eval(compile(exp, "<lambda>", "eval"), GLOBALS)
    assert isinstance(fouter, types.FunctionType)
    finner = fouter(**env)
    assert isinstance(finner, types.FunctionType)
    return finner
def make_lambda ( expression , args , env = None ) : # type: (ast.Expression, List[str], Dict[str, Any]) -> types.FunctionType # lambda *{args}* : EXPRESSION lambda_ = ast . Lambda ( args = ast . arguments ( posonlyargs = [ ] , args = [ ast . arg ( arg = arg , annotation = None ) for arg in args ] , varargs = None , varargannotation = None , kwonlyargs = [ ] , kwarg = None , kwargannotation = None , defaults = [ ] , kw_defaults = [ ] ) , body = expression . body , ) lambda_ = ast . copy_location ( lambda_ , expression . body ) # lambda **{env}** : lambda *{args}*: EXPRESSION outer = ast . Lambda ( args = ast . arguments ( posonlyargs = [ ] , args = [ ast . arg ( arg = name , annotation = None ) for name in ( env or { } ) ] , varargs = None , varargannotation = None , kwonlyargs = [ ] , kwarg = None , kwargannotation = None , defaults = [ ] , kw_defaults = [ ] , ) , body = lambda_ , ) exp = ast . Expression ( body = outer , lineno = 1 , col_offset = 0 ) ast . fix_missing_locations ( exp ) GLOBALS = __GLOBALS . copy ( ) GLOBALS [ "__builtins__" ] = { } # pylint: disable=eval-used fouter = eval ( compile ( exp , "<lambda>" , "eval" ) , GLOBALS ) assert isinstance ( fouter , types . FunctionType ) finner = fouter ( * * env ) assert isinstance ( finner , types . FunctionType ) return finner