class astroid.nodes.Lambda(lineno: int, col_offset: int, parent: NodeNG, *, end_lineno: int | None, end_col_offset: int | None)[source]#

Bases: FilterStmtsBaseNode, LocalsDictNodeNG

Class representing an ast.Lambda node.

>>> import astroid
>>> node = astroid.extract_node('lambda arg: arg + 1')
>>> node
<Lambda.<lambda> l.1 at 0x7f23b2e41518>
argnames() list[str][source]#

Get the names of each of the arguments, including that of the collections of variable-length arguments (“args”, “kwargs”, etc.), as well as positional-only and keyword-only arguments.


The names of the arguments.

Return type:


args: Arguments#

The arguments that the function takes.

body: NodeNG#

The contents of the function body.

bool_value(context: InferenceContext | None = None) Literal[True][source]#

Determine the boolean value of this node.


The boolean value of this node. For a Lambda this is always True.

callable() Literal[True][source]#

Whether this node defines something that is callable.


Whether this defines something that is callable For a Lambda this is always True.

display_type() str[source]#

A human readable type of this node.


The type of this node.

Return type:


frame(*, future: Literal[None, True] = None) _T[source]#

The node’s frame node.

A frame node is a Module, FunctionDef, ClassDef or Lambda.


The node itself.


Get the child nodes below this node.

getattr(name: str, context: InferenceContext | None = None) list[NodeNG][source]#
implicit_parameters() Literal[0][source]#
infer_call_result(caller: SuccessfulInferenceResult | None, context: InferenceContext | None = None) Iterator[InferenceResult][source]#

Infer what the function returns when called.

is_lambda: ClassVar[bool] = True#
locals: dict[str, list[InferenceResult]]#

A map of the name of a local variable to the node defining it.

name = '<lambda>'#
postinit(args: Arguments, body: NodeNG) None[source]#
pytype() Literal['builtins.instancemethod', 'builtins.function'][source]#

Get the name of the type that this node represents.


The name of the type.

scope_lookup(node: LookupMixIn, name: str, offset: int = 0) tuple[LocalsDictNodeNG, list[NodeNG]][source]#

Lookup where the given names is assigned.

  • node – The node to look for assignments up to. Any assignments after the given node are ignored.

  • name – The name to find assignments for.

  • offset – The line offset to filter statements up to.


This scope node and the list of assignments associated to the given name according to the scope where it has been found (locals, globals or builtin).


The names of special attributes that this function has.

property type: Literal['method', 'function']#

Whether this is a method or function.


‘method’ if this is a method, ‘function’ otherwise.