Scripting Guide > Extending JMP > Work with Python > Python Name() and Python Send() Examples
发布日期: 04/13/2021

Python Name() and Python Send() Examples

The following example creates the jmp var name variable, assigns it to the Python name python_var_name, submits the print statement, and closes the connection.

Python Init();
jmp var name = 25;
Python Send( jmp var name, Python Name( "python_var_name" ) );
Python Submit( "print(python_var_name)" );
Python Term();

25.0

 

0

The following example creates a variable x in the Here namespace, a variable y in the global namespace, and a variable z that is not explicitly referenced to any namespace. The variable z defaults to Global unless Names Default To Here(1) is on. These variables are then passed to Python.

Here:x = 1;
::y = 2;
z = 3;
 
Python Init(); // initiate the Python connection
 

/* send the Here variable to Python

Here:x creates the Python object Here_x */

Python Send( Here:x );
 
Python Submit( "print(Here_x)" );
 
Python Send( ::y ); // ::y creates the Python object y
Python Submit( "print(y)" );
 

// to use a different name for the Python object, use the Python Name() option

Python Send( Here:x, Python Name( "localx" ) );
 

/* The Python Name option to the Python Send() command creates the Python object named "localx", which corresponds to the JMP variable "Here:x". */

Python Submit( "print(localx)" );
Python Send( z ); // z creates the Python object z
Python Submit( "print(z)" );
Python Term();

1.0

 

2.0

 

1.0

 

3.0

 

0.0

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).