Solution
TestStand 2019 and above come with the feature of a built-in Python adapter, enabling user to use Python scripting in TestStand.
The Python script below will be used as an example to learn how to configure the step setting of the Python action step to access various elements within the code
double_attribute = 10.0
int_attribute = 20
bool_attribute = False
string_attribute = "Hello"
tuple_attribute = ()
list_attribute = [30, 40, 50, 60, 70]
def definition_1(x, y):
print("Test 1")
return x
def definition_2(x, y):
print("Test 2")
return y
class Demo(object):
test_1 = 0
test_2 = 1
test_3 = 1
def __init__(self, first, last, population):
self.first = first
self.last = last
self.population = 3
self.population += 1
def demo_function(self, example):
example.test_1 = 0
test_2 = 1
class Demo2(object):
test_11 = 0
test_22 = 1
def __init__(self, first, last):
self.first = first
self.last = last
# Note: self.population is used here but not defined in __init__
self.population += 1
def demo_function_2(self, example_2):
example_2.test_1 = 0
test_2 = 1
def definition_3(x, y):
print("Test")
return x
The image below illustrates the step settings for a Python action step:
First, we have to define which Python module the Python action step should call. This can be done by clicking the Browse for Python Module button:

After the desired module is selected, the user will observe the following changes:
- The module will show the filename of the Python script selected.
- The namespace will be the filename of the Python script without file extension.
- The operation scope will be module by default.
- The operation type will be call method by default.
- The function name will be empty by default.
- All other settings will be either greyed out.
To call a method within the module, the following step settings are needed:

To write/set a value to a module attribute, the following step settings are needed:

To read/get a value for a module attribute, the following step settings are needed:

Note: To read/get a module attribute, or to write/set a module attribute, remember to configure a variable to store the returned value and set the argument to the value to write, as indicated by the arrows in the images above.
To access a class with its properties and methods within a Python code from TestStand, we have to create a class instance as shown below:

Note:
- Ensure an object reference type variable is created to store the class instance reference created.
- Remember to fill up the arguments as pointed by the red arrow in the image above if the class initialisation needs it to assign value for its properties.
Lastly, the process to access the methods and properties within the class is almost similar for the module, but in this case, the operation scope has to be Class Instances, and we have to fill up the Class Instance with the variable storing the class instance reference created in the previous step. The image below is a sample for this step:
