Post Reply 
HP Prime Python runs consecutive programs
09-23-2023, 05:57 PM
Post: #2
RE: HP Prime Python runs consecutive programs
(09-22-2023 07:42 PM)Pellidon Wrote:  I have two scripts. When the first one is done, the second imports and runs. This does not occur on my Casio, Numworks or either TI calculators with Python. When the second one is done, it does not import back to the first file. Very strange.
Unfortunately the Prime doesn't allow for selected imports or runs. One work around is to enclose all programs in "def xx():" you do this on the Numworks too usually, don't you?

Consider you have 2 programs "main" and "another"

Then "main" may have as content:
Code:
def foobar():
    print("this is from main")

and "another" may have as content:
Code:
def foobar():
    print("this is from another")
Then upon starting Python you'll see both modules imported but not executed.

Entering "main.foobar()" will then show: "this is from main"
consequently
"another.foobar()" will then show: "this is from another"

That's a bit cumbersome, hopefully someone does a thorough repair on the Python implementation.

I'll elaborate a bit on this at the HHUC at Orlando.
HTH Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP Prime Python runs consecutive programs - Guenter Schink - 09-23-2023 05:57 PM



User(s) browsing this thread: 1 Guest(s)