Esperaba integrar Python en JMP JSL (versión 17.2). Necesito hacer un anidamiento complejo pero parece que ni siquiera puedo hacer algo simple. El índice de secuencias de comandos para Python Submit muestra que Python genera una variable y luego se introduce en JSL mediante 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();
Esperaba comenzar con algo simple como esto y luego avanzar a algo más avanzado:
Python Submit("\[
for i in range(10):;
if i == 6:;
print(i);
]\");Esperaba que la terminal solo imprimiera un seis, sin embargo, después de ejecutar el script, el resultado fue un poco extraño.
//Terminal Output<BR />/**********/<BR /><BR />for i in range(10):;<BR />if i == 6:;<BR />print(i);<BR />/**********/
Probé un poco más y descubrí que un par de cosas funcionan. Pero todavía no puedo hacer que funcionen los bucles anidados.
//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)");<BR />Python Submit("for i in range(10): if i == 6:; print(i););Si alguien tiene algún consejo sería muy apreciado.
Aquí están las estructuras de envío en la interfaz JMP 17 a Python que encontré que funcionan.
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')
");Si puede actualizar a JMP18, se ahorrará muchos posibles dolores de cabeza debido a la nueva forma de manejar Python en JMP.
Parece que pasaste por alto las sangrías necesarias.
Python Submit("\[
for i in range(10):
if i == 6:
print(i)
]\"); //6 (then 0 when Python is successfully terminated)No me di cuenta de que la sangría tuviera un impacto tan grande en jmp. ¡Gracias por la ayuda!
No tiene un impacto en JMP pero sí en Python (está ejecutando código Python, no JSL).