This example initiates the Python connection, sends a character variable, a numeric variable, and a set of matrices to Python. Python is then instructed to perform a set of matrix operations on the sent matrices. The Python Execute() function then get the set of matrices created by the matrix operations and gets the values of the character and numeric variables that was originally sent. Upon completion of the data retrieval, the Python connection is closed.
Python Init();
a = "abcdef";
d = 3.141;
v = [9 8 7, 6 5 4, 3 2 1];
m = [1 2 3, 4 5 6, 7 8 9];
ml = Python Execute(
	{v, m, a, d},
	{x1, x2, y1, y2, z1, z2, a, d},
	"\[
import numpy as np
x1 = np.multiply(v, m) # matrix product
print('x1=', x1)
x2 = np.divide(v, m) # matrix division
print('x2=', x2)
y1 = np.dot(v, m) # dot product of v and m
print('y1=', y1)
y2 = np.dot(m, v) # dot product of m and v
print('y2=', y2)
z1 = np.inner(v, m) # inner product of v and m
print('z1=', z1)
z2 = np.inner(m, v) # inner product of m and v
print('z2=', z2)
]\"
);
Show( v, m, ml, x1, x2, y1, y2, z1, z2, a, d );
Python Term();
x1= [[  9.  16.  21.]
 [ 24.  25.  24.]
 [ 21.  16.   9.]]
x2= [[ 9.          4.          2.33333333]
 [ 1.5         1.          0.66666667]
 [ 0.42857143  0.25        0.11111111]]
...
 
Python Init(); // initiate the Python connection
 
qbx = "The right stuff";
Python Send( qbx );
// send the qbx variable and sample data table "Animals.jmp" to Python
 
dt = Open( "$SAMPLE_DATA/Animals.jmp" );
Python Send( dt );
Close( dt, nosave );
 
qbx = Python Get( qbx );
// get the Python variable qbx and place it into a JMP variable qbx
 
df = Python Get( dt );
/* get the Python variable dt and place it into a JMP data table
	referenced by df */
 
Python Term();
 
Show( qbx );
df << New Data View;
Wait( 10 );
Close( df, nosave );
Python Term();
qbx = "The right stuff";
0
Optional. Performs an Eval Insert() on the Python code before submission.
Python Init(); // initiate the Python connection
commands =
"
friends = ['john', 'pat', 'gary', 'michael']
print(friends)
for i, name in enumerate(friends):
    print( \!"iteration {iteration} is {name}\!".format(iteration=i, name=name))
";
Python Submit( commands );
Python Term();
['john', 'pat', 'gary', 'michael']
iteration 0 is john
iteration 1 is pat
iteration 2 is gary
iteration 3 is michael
 
0

Help created on 1/2/2019