• Home
  • Raw
  • Download

Lines Matching +full:visitor +full:- +full:keys

1 :mod:`ast` --- Abstract Syntax Trees
16 --------------
24 a flag to the :func:`compile` built-in function, or using the :func:`parse`
27 compiled into a Python code object using the built-in :func:`compile` function.
30 .. _abstract-grammar:
33 ----------------
42 ------------
48 :ref:`above <abstract-grammar>`. They are defined in the :mod:`_ast` C
49 module and re-exported in :mod:`ast`.
51 There is one class defined for each left-hand side symbol in the abstract
53 there is one class defined for each constructor on the right-hand side; these
54 classes inherit from the classes for the left-hand side trees. For example,
56 with alternatives (aka "sums"), the left-hand side class is abstract: only
73 zero-or-more values (marked with an asterisk), the values are represented
85 are the first and last line numbers of source text span (1-indexed so the
87 are the corresponding UTF-8 byte offsets of the first and last tokens that
88 generated the node. The UTF-8 offset is recorded because the parser uses
89 UTF-8 internally.
93 one can get the source segment of a one-line expression node using
168 Node representing a single formatting field in an f-string. If the string
176 * -1: no formatting
188 An f-string, comprising a series of :class:`FormattedValue` and :class:`Constant`
200 conversion=-1),
208 conversion=-1,
256 .. class:: Dict(keys, values)
258 A dictionary. ``keys`` and ``values`` hold lists of nodes representing the
259 keys and the values respectively, in matching order (what would be returned
260 when calling :code:`dictionary.keys()` and :code:`dictionary.values()`).
264 position in ``keys``.
271 keys=[
359 >>> print(ast.dump(ast.parse('-a'), indent=4))
538 Attribute access, e.g. ``d.keys``. ``value`` is a node, typically a
669 each element - typically a :class:`Name` or :class:`Tuple` node. ``iter``
1204 typically a :class:`Name` node (or ``None`` for a catch-all ``except:`` clause).
1463 .. class:: MatchMapping(keys, patterns, rest)
1465 A match mapping pattern. ``keys`` is a sequence of expression nodes.
1493 keys=[
1503 pattern=MatchMapping(keys=[], patterns=[], rest='rest'),
1519 all positional patterns match the corresponding class-defined attributes, and
1575 A match "as-pattern", capture pattern or wildcard pattern. ``pattern``
1616 A match "or-pattern". An or-pattern matches each of its subpatterns in turn
1617 to the subject, until one succeeds. The or-pattern is then deemed to
1618 succeed. If none of the subpatterns succeed the or-pattern fails. The
1697 * ``kw_defaults`` is a list of default values for keyword-only arguments. If
1719 ... def f(a: 'annotation', b=1, c=2, *d, e, f=3, **g) -> 'return annotation':
1828 Other keywords will be passed to the metaclass, as per `PEP-3115
1829 <https://peps.python.org/pep-3115/>`_.
1917 ------------------
1939 e.g. ``(str, int) -> List[str]``.
2045 If *padded* is ``True``, the first line of a multi-line statement will
2095 A node visitor base class that walks the abstract syntax tree and calls a
2096 visitor function for every node found. This function may return a value
2099 This class is meant to be subclassed, with the subclass adding visitor
2110 This visitor calls :meth:`visit` on all children of the node.
2112 Note that child nodes of nodes that have a custom visitor method won't be
2113 visited unless the visitor calls :meth:`generic_visit` or visits them
2117 during traversal. For this a special visitor exists
2134 the visitor methods to replace or remove the old node. If the return value
2135 of the visitor method is ``None``, the node will be removed from its
2156 statement nodes), the visitor may also return a list of nodes rather than
2162 the new sub-tree to recalculate the location information::
2182 If *indent* is a non-negative integer or string, then the tree will be
2183 pretty-printed with that indent level. An indent level
2193 .. _ast-compiler-flags:
2196 --------------
2203 Enables support for top-level ``await``, ``async for``, ``async with``
2221 .. _ast-cli:
2223 Command-Line Usage
2224 ------------------
2231 .. code-block:: sh
2233 python -m ast [-m <mode>] [-a] [infile]
2239 .. cmdoption:: -h, --help
2243 .. cmdoption:: -m <mode>
2244 --mode <mode>
2249 .. cmdoption:: --no-type-comments
2253 .. cmdoption:: -a, --include-attributes
2257 .. cmdoption:: -i <indent>
2258 --indent <indent>
2271 `ASTTokens <https://asttokens.readthedocs.io/en/latest/user-guide.html>`_
2276 `leoAst.py <https://leoeditor.com/appendices.html#leoast-py>`_ unifies the
2277 token-based and parse-tree-based views of python programs by inserting
2278 two-way links between tokens and ast nodes.
2286 error recovery and round-trip parsing for different Python versions (in