TenjintShell.run_ast_nodes

TenjintShell.run_ast_nodes(nodelist: List[_ast.AST], cell_name: str, interactivity='last_expr', compiler=<built-in function compile>, result=None)

Run a sequence of AST nodes. The execution mode depends on the interactivity parameter.

Parameters
  • nodelist (list) – A sequence of AST nodes to run.

  • cell_name (str) – Will be passed to the compiler as the filename of the cell. Typically the value returned by ip.compile.cache(cell).

  • interactivity (str) – ‘all’, ‘last’, ‘last_expr’ , ‘last_expr_or_assign’ or ‘none’, specifying which nodes should be run interactively (displaying output from expressions). ‘last_expr’ will run the last node interactively only if it is an expression (i.e. expressions in loops or other blocks are not displayed) ‘last_expr_or_assign’ will run the last expression or the last assignment. Other values for this parameter will raise a ValueError.

  • compiler (callable) – A function with the same interface as the built-in compile(), to turn the AST nodes into code objects. Default is the built-in compile().

  • result (ExecutionResult, optional) – An object to store exceptions that occur during execution.

Returns

  • True if an exception occurred while running code, False if it finished

  • running.