Lambda¶
- 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.
- bool_value(context: InferenceContext | None = None) Literal[True] [source]¶
Determine the boolean value of this node.
- Returns:
The boolean value of this node. For a
Lambda
this is alwaysTrue
.
- callable() Literal[True] [source]¶
Whether this node defines something that is callable.
- Returns:
Whether this defines something that is callable For a
Lambda
this is alwaysTrue
.
- display_type() str [source]¶
A human readable type of this node.
- Returns:
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
orLambda
.- Returns:
The node itself.
- infer_call_result(caller: SuccessfulInferenceResult | None, context: InferenceContext | None = None) Iterator[InferenceResult] [source]¶
Infer what the function returns when called.
- locals: dict[str, list[InferenceResult]]¶
A map of the name of a local variable to the node defining it.
- name = '<lambda>'¶
- pytype() Literal['builtins.instancemethod', 'builtins.function'] [source]¶
Get the name of the type that this node represents.
- Returns:
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.
- Parameters:
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.
- Returns:
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).
- special_attributes¶
The names of special attributes that this function has.