Managing Scripts
At Apple’s request, we had to remove the capability to load scripts from outside the app via iTunes file sharing and “Open in…” in version 1.5. We’re partially sympathetic to their concerns. After all, there really is no 100% reliable way to assure a given script isn’t malicious. At least they didn’t ban executing Python scripts totally.
Coming soon to make up for this is a built-in editor. Since the iPhone and iPad support paste universally, paste into the editor will become the primary way to get scripts into Python Math.
You can load your own scripts into Python Math in these ways:
iTunes File Sharing — iTunes provides the capability to load Python Math scripts (file extension .py) via the iTunes Apps tab. Once loaded, you can execute these scripts with either import or execfile(). See this Apple KB article for details about how to use iTunes file sharing.
Email — Python Math recognizes .py email attachments. If you open the attachment with Python Math, it will copy the script into Python Math and execute the script with execfile().
Dropbox — Since .py files are registerd as a file format that Python Math recognizes, you can execute them from Dropbox and other apps that store and sync documents. As with email attachments, Python Math copies the script into its own storage and then executes it with execfile().
Executing Scripts
Execute this Python command to view a list of scripts you’ve accumulated using these methods:
os.listdir(".")
Execute any of these scripts with either the import or
execfile() Python command. Examples:
import hpm
execfile("hpm.py")
(The script hpm.pywas preloaded into your scripts folder by Python Math.)
Start-Up Script
If a script named PYTHONSTARTUP.py exists, it will be executed using execfile() upon starting Python Math and restarting the interpreter.