class documentation

class Lambda(mixins.FilterStmtsMixin, LocalsDictNodeNG): (source)

Known subclasses: astroid.nodes.scoped_nodes.FunctionDef

View In Hierarchy

Class representing an ast.Lambda node.

>>> import astroid
>>> node = astroid.extract_node('lambda arg: arg + 1')
>>> node
<Lambda.<lambda> l.1 at 0x7f23b2e41518>
Method __init__
Method argnames Get the names of each of the arguments.
Method bool​_value Determine the boolean value of this node.
Method callable Whether this node defines something that is callable.
Method display​_type A human readable type of this node.
Method frame The node's frame node.
Method get​_children Undocumented
Method implicit​_parameters Undocumented
Method infer​_call​_result Infer what the function returns when called.
Method postinit Do some setup after initialisation.
Method pytype Get the name of the type that this node represents.
Method scope​_lookup Lookup where the given names is assigned.
Class Variable is​_lambda Undocumented
Class Variable name Undocumented
Instance Variable args The arguments that the function takes.
Instance Variable body The contents of the function body.
Instance Variable locals A map of the name of a local variable to the node defining it.
Property type Whether this is a method or function.
Class Variable _astroid​_fields Undocumented
Class Variable _other​_other​_fields Undocumented

Inherited from FilterStmtsMixin:

Method assign​_type Undocumented
Method _get​_filtered​_stmts method used in _filter_stmts to get statements and trigger break

Inherited from LocalsDictNodeNG:

Method __contains__ Check if a local is defined in this scope.
Method __getitem__ The first node the defines the given local.
Method __iter__ Iterate over the names of locals defined in this scoped node.
Method add​_local​_node Append a child that should alter the locals of this scope node.
Method items Get the names of the locals and the node that defines the local.
Method keys The names of locals defined in this scoped node.
Method qname Get the 'qualified' name of the node.
Method scope The first parent node defining a new scope.
Method set​_local Define that the given name is declared in the given statement node.
Method values The nodes that define the locals in this scoped node.
Method _append​_node append a child, linking it in the tree
Method _scope​_lookup XXX method for interfacing the scope lookup

Inherited from LookupMixIn (via LocalsDictNodeNG):

Method ilookup Lookup the inferred values of the given variable.
Method lookup Lookup where the given variable is assigned.
def __init__(self, lineno=None, col_offset=None, parent=None, *, end_lineno=None, end_col_offset=None): (source)
Parameters
lineno:int or NoneThe line that this node appears on in the source code.
col​_offset:int or NoneThe column that this node appears on in the source code.
parent:NodeNG or NoneThe parent node in the syntax tree.
end​_lineno:Optional[int]The last line this node appears on in the source code.
end​_col​_offset:Optional[int]The end column this node appears on in the source code. Note: This is after the last symbol.
def argnames(self): (source)
Get the names of each of the arguments.
Returns
list(str)The names of the arguments.
def bool_value(self, context=None): (source)
Determine the boolean value of this node.
Returns
boolThe boolean value of this node. For a Lambda this is always True.
def callable(self): (source)
Whether this node defines something that is callable.
Returns
boolTrue if this defines something that is callable, False otherwise. For a Lambda this is always True.
def display_type(self): (source)
A human readable type of this node.
Returns
strThe type of this node.
def frame(self, *, future=None): (source)

The node's frame node.

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

Parameters
future:Literal[None, True]Undocumented
Returns
TThe node itself.
def get_children(self): (source)

Undocumented

def implicit_parameters(self): (source)

Undocumented

def infer_call_result(self, caller, context=None): (source)
Infer what the function returns when called.
Parameters
caller:objectUnused
contextUndocumented
def postinit(self, args, body): (source)
Do some setup after initialisation.
Parameters
args:ArgumentsThe arguments that the function takes.
body:list(NodeNG)The contents of the function body.
def pytype(self): (source)
Get the name of the type that this node represents.
Returns
strThe name of the type.
def scope_lookup(self, node, name, offset=0): (source)
Lookup where the given names is assigned.
Parameters
node:NodeNGThe node to look for assignments up to. Any assignments after the given node are ignored.
name:strThe name to find assignments for.
offset:intThe line offset to filter statements up to.
Returns
tuple(str, list(NodeNG))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).
is_lambda: bool = (source)

Undocumented

name: str = (source)

Undocumented

args = (source)
The arguments that the function takes.
body = (source)
The contents of the function body.
locals: dict = (source)
A map of the name of a local variable to the node defining it.
@property
type: str = (source)
Whether this is a method or function.
Returns
'method' if this is a method, 'function' otherwise.
_astroid_fields: tuple[str, ...] = (source)

Undocumented

_other_other_fields: tuple[str, ...] = (source)

Undocumented