Skip to content

synt.stmt.block ¤

Block ¤

Bases: Statement

A Python code block.

Source code in synt/stmt/block.py
class Block(Statement):
    r"""A Python code block."""

    body: list[Statement]
    """Code lines in the block."""

    def __init__(self, *args: Statement):
        """Initialize a new code block.

        Args:
            args: code lines.
        """
        self.body = list(args)

    def indented(self, indent_width: int, indent_atom: str) -> str:
        return "\n".join(
            f"{line.indented(indent_width, indent_atom)}" for line in self.body
        )

body instance-attribute ¤

body: list[Statement] = list(args)

Code lines in the block.

__init__ ¤

__init__(*args: Statement)

Initialize a new code block.

Parameters:

Name Type Description Default
args Statement

code lines.

()
Source code in synt/stmt/block.py
def __init__(self, *args: Statement):
    """Initialize a new code block.

    Args:
        args: code lines.
    """
    self.body = list(args)

indented ¤

indented(indent_width: int, indent_atom: str) -> str
Source code in synt/stmt/block.py
def indented(self, indent_width: int, indent_atom: str) -> str:
    return "\n".join(
        f"{line.indented(indent_width, indent_atom)}" for line in self.body
    )