Beginner: How do you run a Python program?
|
10-07-2024, 03:02 PM
(This post was last modified: 10-08-2024 05:39 PM by StephenG1CMZ.)
Post: #1
|
|||
|
|||
Beginner: How do you run a Python program?
Now that Python has finally reached HP Prime Android, after several years on the actual calculator, perhaps those more experienced can give beginners a few clues.
Here's what I have discovered so far: It seems to be micro python 3.4. Upon entering the App, ignore "Save" and "Load" menus - they don't save and Load files. Press "Symbol" to see programs, and you will see a "More" menu. That's where you will find Files you have created. (They are separate from PPL and CAS programs). Press "Num" to see earlier program results. After editing a program, when you re-enter Python App you may be asked if you want to run edited files. Selecting Yes flashes some output on the screen and the App crashes back to Android. Is this a bug? Restarting the calculator and Python gets you back to the point where you can press "Symb" to see files...there's no "run" menu (by comparison, PPL has both Run and Debug). I have seen program output, but it is not clear how best to reliably run a program (hence I can't yet confirm the Python version number). Syntax errors give a line number, but don't drop you into an edit screen. Once past these beginners hurdles, there is an impressive range of modules (but no numpy). It seems it can even read data files - very rare if not unique on calculator implementations. A "getting started" guide would be a great help. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-07-2024, 04:25 PM
Post: #2
|
|||
|
|||
RE: Beginner: How do you run a Python program?
It seems there are a few solutions to running the program in this thread:
https://www.hpmuseum.org/forum/thread-20...Python+app Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-07-2024, 05:42 PM
(This post was last modified: 10-07-2024 05:45 PM by komame.)
Post: #3
|
|||
|
|||
RE: Beginner: How do you run a Python program?
The HP Prime currently has an implementation of Micropython version 1.9.4, which can be checked with:
Code: import sys The latest version of Micropython is currently 1.23.0 [doc]. There is no such thing as Load and Save menus in the Python App. These menus are simply in the Home view, regardless of the active application. They allow for saving and loading the history of calculations (the history stack). As for the syntax error and jumping to the line of the program where the error occurred, this has worked correctly since Python has been available on the HP Prime (a popup with error information appears, and when you click OK, it takes you to the line where the error occurred). When the Python application is active, pressing Symb allows you to enter your program, and then pressing Num and confirming file imports, you can run it. Pressing OK for confirmation should not cause a reset/restart; this may be a bug in the Android version. You can also create your own application (with an icon in the Application Library) that will immediately run your program without the need to switch between Symb and Num. Mike (ab3ap here) has prepared a nice tutorial for beginners, and I think it's worth reading. If you have any specific questions about Python on the HP Prime, feel free to ask. Piotr Kowalewski |
|||
10-08-2024, 01:50 PM
Post: #4
|
|||
|
|||
RE: Beginner: How do you run a Python program?
After uninstalling and reinstalling the app, it now seems to run the program upon re-entering the python app (I'm now using main.py rather than tryp.py, if that makes a difference).
And syntax errors now offer to take you to the edit line. Seems much better now. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-08-2024, 05:05 PM
(This post was last modified: 10-09-2024 10:17 AM by StephenG1CMZ.)
Post: #5
|
|||
|
|||
RE: Beginner: How do you run a Python program?
Unfortunately that ease of running Python was only temporary.
Since importing code from the mobile, the difficulties have returned. Tried another reinstall, but that hasn't helped. (update: a 2nd reinstall helped briefly) Python says files have changed, do you want to run? Ok flashes up an import screen and crashes. Can Python run scripts imported from Android mobiles? Deleting the imported code doesn't help, it still crashes. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-09-2024, 11:20 AM
Post: #6
|
|||
|
|||
RE: Beginner: How do you run a Python program?
There's a great video from HHC 2023, by Günter Schink
"HHC 2023: Python on Prime: A Personal Experience (Günter Schink)" in YT. https://www.youtube.com/watch?v=-PLt2khyAik |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)