Skip to content

python

ASTx Python transpiler.

Modules:

Classes:

ASTxPythonTranspiler

ASTxPythonTranspiler()

Transpiler that converts ASTx nodes to Python code.

Notes

Please keep the visit method in alphabet order according to the node type. The visit method for astx.AST should be the first one.

Methods:

  • visit

    Handle LiteralDateTime nodes.

Source code in src/astx/tools/transpilers/python.py
21
22
23
def __init__(self) -> None:
    self.indent_level = 0
    self.indent_str = "    "  # 4 spaces

visit

visit(node: LiteralDateTime) -> str

Handle LiteralDateTime nodes.

Source code in src/astx/tools/transpilers/python.py
395
396
397
398
@dispatch  # type: ignore[no-redef]
def visit(self, node: astx.LiteralDateTime) -> str:
    """Handle LiteralDateTime nodes."""
    return f"datetime.strptime({node.value!r}, '%Y-%m-%dT%H:%M:%S')"