Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Coding #1

Closed
defencedog opened this issue Oct 19, 2022 · 4 comments
Closed

Python Coding #1

defencedog opened this issue Oct 19, 2022 · 4 comments
Assignees

Comments

@defencedog
Copy link

With latest firmware Python is enabled in HP Prime. I have some question regarding it. Will you help

@MarcPerezPro
Copy link
Owner

Hi @defencedog
Unfortunately I haven't tried the Python interpreter on my HP Prime G2.
But I'm sure it's way easier to program than HP PPL, and there are plenty of Python tutorials online.
Just remember that you can't use any fancy library, so you're going to spend some time reinventing the wheel.

@defencedog
Copy link
Author

@return-main I just want to know if variables can somehow shared between python & PPL. I mean say my python returns a list in a variable how can I assign it to HP Prime native L1 list variable for plots & stuff

@MarcPerezPro MarcPerezPro self-assigned this Nov 11, 2022
@MarcPerezPro MarcPerezPro pinned this issue Nov 11, 2022
@MarcPerezPro
Copy link
Owner

@defencedog I'm sorry for the delay, I was busy organizing my marriage 👰‍♂️

This was much harder than expected, but I made you a proof of concept:
https://gist.github.com/return-main/b7071adad860a300fd07ad51cc54fe80

#PYTHON PY_RANGE
import sys
var_from = int(sys.argv[0])
var_to = int(sys.argv[1])
l=list(range(var_from,var_to))
print("{"+str(l)[1:-1]+"}")
#END

EXPORT RANGE(var_from,var_to)
BEGIN
  // clear the Terminal
  PRINT;
  // run the Python script
  PYTHON(PY_RANGE,var_from,var_to);
  // evaluate the string in the Terminal and return to the stack
  RETURN EXPR(TERMINAL(1));
END;

@defencedog
Copy link
Author

@return-main Extremely Thanks & Congratz on your marriage.

Your idead is very welcome. I have experimented with python greatly & you can visit my playground
https://github.com/defencedog/HP-Prime-Advance/tree/main/Scripts_Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants