nodify.conversions.node_to_python_script

nodify.conversions.node_to_python_script(output_node: Node, include_defaults: bool = False, as_function: bool = False, function_name: str | None = 'function', names_map: Dict[int, str] = {})[source]

Converts the tree leading to a given node into a Python script.

Parameters:
  • output_node – The node whose output the script will generate.

  • include_defaults – Whether to include the default inputs of the functions in the script.

  • as_function – Whether to write the code defining a function that encapsulates all the computation needed. If False, the script will be a sequence of variable assignments.

  • function_name – The name of the function to be created if as_function is True.

  • names_map – A dictionary mapping the id of a node to a custom name. The name will be used for the variable containing the value that the node returns.