NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple outputs for python step

Solved!
Go to solution

Python list maps to TestStand array. The only constraint is that, all elements of the list must be of same type.

If the constraint is OK, you can return the list from the function and store it in an array variable.

 

Any Python object returned from the function can be stored in a variable of type 'Object Reference'. You can also pass the same object as input for other functions. So, if you return a Python dict, you can store it in 'Object Reference' type variable. Disadvantage will be logging. If you log the 'Object Reference' object, the report does not show entire content of the Python object. If you do not want to log the Python dict data, you can consider this approach.

 

As you already know, Python tuples maps to TestStand container. This should be the preferred solution if each element of the tuple is of different type. Also, unlike the 'Object Reference' object mentioned earlier, this does not have any disadvantage in terms of logging.

 

-Shashidhar

Message 11 of 12
(221 Views)

Shashidhar

 

I do not and have never had to return multiple values like you showed using Python ... I do it using the example I showed previously and have been doing it that way for over 10 years in both Python 2 and 3 ... Python may use tuples internally to pass multiple values but within Python I can put the multiple values on the left side of the equals.

 

The TestStand implementation requires the data from Python in a tuple that is assigned to the resulting container if you are passing back more that a single element of different types such as a string, bool, and int. Using containers allows you to use a name instead of requiring you to know what the different indexes mean if you return an array of values so that your code is more readable and it also gives you a way of verifying expected data is in the correct type.

0 Kudos
Message 12 of 12
(128 Views)