HP Forums
Pass parameter to Python? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Pass parameter to Python? (/thread-20468.html)



Pass parameter to Python? - toml_12953 - 09-07-2023 11:22 AM

How can I pass a parameter or parameters to a Python program called in an HPPL shell? The below doesn't work.

Code:
#PYTHON myfunc(x)
print(x);
#END

EXPORT PassParm(y)
BEGIN
myfunc(y);
END;



RE: Pass parameter to Python? - roadrunner - 09-07-2023 11:55 AM

Try this:

Code:
#PYTHON myfunc
from sys import argv
print(argv[0]);
#END

EXPORT PassParm(y)
BEGIN
 PYTHON(myfunc,y);
END;

-road


RE: Pass parameter to Python? - toml_12953 - 09-08-2023 03:05 AM

(09-07-2023 11:55 AM)roadrunner Wrote:  Try this:

Code:
#PYTHON myfunc
from sys import argv
print(argv[0]);
#END

EXPORT PassParm(y)
BEGIN
 PYTHON(myfunc,y);
END;

-road

Thanks! That works fine. I ended up using this


Code:
#PYTHON myfunc(a)
from sys import argv
print(argv[0]);
#END

EXPORT PassParm(y)
BEGIN
  myfunc(y);
END;