INNER CODE UNIT · Python

Executor

iamgreggarcia/codesherpa · executors/executor.py:20

class Executor(abc.ABC):
    @abc.abstractmethod
    def execute(self, code: str) -> str:
        pass


class PythonExecutor(Executor):
    locals = {}

    def execute(self, code: str) -> str:
        logger.info("Executing Python code: {}", code)
        output = io.StringIO()

        # Parse the code into an AST.
        tree = ast.parse(code, mode="exec")

        try:
            # Redirect standard output to our StringIO instance.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…