Using Optional Arguments with Python Node in LabVIEW

Updated Oct 17, 2018

Reported In

Software

  • LabVIEW 2018
  • LabVIEW 2018 SP1

Other

Python

Issue Details

Does the Python Node in LabVIEW support optional arguments? How do I use a Python method with optional arguments in LabVIEW? 

Solution

Python Nodes in LabVIEW do support optional arguments. The main consideration is that all required arguments must come before optional arguments.

For example, let's look at a Python method with 5 inputs where the first 3 are required while the last 2 are optional. In LabVIEW, you would only have to provide the first three inputs and the code will execute correctly using the default value for the 2 optional arguments that are not defined. You can also choose to expand the Python node and feed in all 5 inputs and the Python method will execute with all 5 provided inputs. However, if the optional arguments are the first 2 inputs of the method, they cannot be skipped since you will have to define those two inputs before you get to the optional ones. 

When creating Python scripts that you intend to use in LabVIEW, make sure to list the required inputs first and the optional arguments last.