Calls a Python function directly.

The Python Node is expandable and shows data types for the wired inputs and outputs. You can configure the Python Node to specify the Python session, module path, and function name.

The Python Node is not supported on real-time or FPGA targets.


icon

Inputs/Outputs

  • cgnrn.png session in

    session in specifies a reference to the Python session. One or more Python Nodes can run in a single Python session.

  • cpath.png module path

  • cstr.png function name

  • cerrcodeclst.png error in (no error)

    return type specifies the data type of return value.

    You must wire the data type to return type to indicate the expected data type of return value. If the Python function does not return any value, leave return type unwired.
  • cpoly.png return type

  • cpoly.png input parameter

  • ignrn.png session out

    session out returns a reference to the Python session.

  • ierrcodeclst.png error out

    return value is the return value of the Python function.

  • ipoly.png return value

  • ipoly.png

  • Supported Data Types

    The Python Node supports a large number of data types. You can use this node to call the following data types:

    • Numerics
    • Arrays, including multi-dimensional arrays
    • Strings
    • Clusters
    • Booleans

    Calling Conventions

    This node converts integers, strings, and Booleans to the corresponding data types in Python, converts arrays to lists or NumPy arrays, and converts clusters to tuples.

    Marshaling Arrays to Lists or NumPy Arrays

    By default, the Python Node marshals arrays to lists. To marshal an array wired to input parameter to a NumPy array, right-click input parameter and select Marshal to NumPy Array from the shortcut menu.

    Note You can marshal only numeric arrays to NumPy arrays.

    Marshaling Clusters to Named Tuples

    By default, the Python Node marshals clusters to tuples. In Python, you can only reference items in a tuple by index and iterator. Python supports named tuples, which allow you to reference items by name as well. If you want to reference named tuple items by name, you must marshal clusters to named tuples. To marshal a cluster wired to an input parameter to a named tuple, right-click input parameter and select Marshal to Namedtuple from the shortcut menu.

    Debugging Python Code

    The Python Node provides options for debugging by stepping into the code in VSCode. To read more about debugging Python code, refer to this documentation.