About 4,430,000 results
Open links in new tab
  1. Using python's eval () vs. ast.literal_eval () - Stack Overflow

    174 ast.literal_eval() only considers a small subset of Python's syntax to be valid: The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, …

  2. Using python AST to traverse code and extract return statements

    Aug 27, 2024 · Using python AST to traverse code and extract return statements Asked 1 year, 3 months ago Modified 1 year, 2 months ago Viewed 3k times

  3. How can I obtain the full AST in Python? - Stack Overflow

    In Python 2.6's module ast you also get helpers to let you navigate more easily on a tree (e.g. by the Visitor design pattern) -- but the whole tree is there in either 2.5 (with _ast) or 2.5 (with ast), and in …

  4. Simple example of how to use ast.NodeVisitor? - Stack Overflow

    Oct 4, 2009 · 65 Does anyone have a simple example using ast.NodeVisitor to walk the abstract syntax tree in Python 2.6? The difference between visit and generic_visit is unclear to me, and I cannot find …

  5. Generating a text representation of Python's AST

    Update for Python 3.9+: The ast.dump function in the standard library now has an optional keyword argument indent for pretty-printing of Python ASTs. You pass either an integer for the number of …

  6. python - How do I list a function's parameters using ast ... - Stack ...

    Jul 10, 2018 · I'm using the ast module to parse docstrings in a Python module to turn our docs into read the docs format. I'm using the following to get the function names and docstrings into a list of dicts …

  7. How do I Parse an AST in Python to Find Just the Variables

    Apr 29, 2020 · The ast.Name node in func represents the method name. args is a list of ast nodes. You might want to do a depth-first search for each node in args, and then look for ast.Name nodes. The …

  8. convert AST node to python code - Stack Overflow

    convert AST node to python code Asked 9 years, 2 months ago Modified 4 years, 6 months ago Viewed 10k times

  9. Python AST with preserved comments - Stack Overflow

    I can get AST without comments using import ast module = ast.parse (open ('/path/to/module.py').read ()) Could you show an example of getting AST with preserved comments (and whitespace)?

  10. Getting parent of AST node in Python - Stack Overflow

    I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, ev...