cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Owen
Level I

JMP 17 and Python

I was hoping to integrate python into JMP JSL (version 17.2). I need to do some complex nesting but I can't even seem to do something simple. The scripting index for Python Submit showcases python generating a variable and then it being pulled into JSL using Python Get. 

//scripting index code
Names Default To Here( 1 );
Python Init();
Python Submit( "\[
str = 'The quick brown fox jumps over the lazy dog';
a = 200;
]\");
getStr = Python Get( str );
getNum = Python Get( a );
Show( getStr, getNum);
Python Term();

I was hoping to start with something simple like this and then advance to something more advanced:

Python Submit("\[
for i in range(10):;
if i == 6:;
print(i);
]\");

I was expecting the terminal to solely print a six however after running the script the result was a bit bizarre.

//Terminal Output
/**********/

for i in range(10):;
if i == 6:;
print(i);
/**********/

I have tested some more and learned that a couple of things work. But I still can't get nested loops to work.

//Code that seemingly works
Python Submit("print('Hello World')");
Python Submit("for i in range(10): print(i); print(i);");

//Code that doesn't work for some reason
Python Submit("for i in range(10):; if i == 6; print(i)");
Python Submit("for i in range(10): if i == 6: print(i)");
Python Submit("for i in range(10): if i == 6:; print(i););

If anyone has any advice it would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JMP 17 and Python

Here is the Submit structures in the JMP 17 interface to Python that I found that work

Names Default To Here( 1 );
Python Init();
Python Submit("\[
for i in range(11):
   if i == 6: 
      print(i)
      print(i)
]\");
Python Submit("i=6
if i == 6: print(i); print('i is 6')
");
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: JMP 17 and Python

Here is the Submit structures in the JMP 17 interface to Python that I found that work

Names Default To Here( 1 );
Python Init();
Python Submit("\[
for i in range(11):
   if i == 6: 
      print(i)
      print(i)
]\");
Python Submit("i=6
if i == 6: print(i); print('i is 6')
");
Jim
Owen
Level I

Re: JMP 17 and Python

I didn't realize that indentation had such a large impact in jmp. Thanks for the help!

jthi
Super User

Re: JMP 17 and Python

It doesn't have an impact in JMP but it does have an impact in Python (you are running Python code not JSL).

-Jarmo
jthi
Super User

Re: JMP 17 and Python

If you are able to update to JMP18 you will save yourself from a lot of possible headache due to the new way of handling Python in JMP.

-Jarmo
mmarchandFSLR
Level IV

Re: JMP 17 and Python

Looks like you overlooked the indentations needed.

 

Python Submit("\[
for i in range(10):
	if i == 6:
		print(i)
]\");     //6 (then 0 when Python is successfully terminated)