What is PyOSA?
PyOSA is an OSA language component for the Python scripting language, allowing Python code to be executed by any OSA-enabled application (Script Editor, Mail, iTunes, etc.). PyOSA makes Python a full peer to AppleScript.
For example, the following PyOSA script will return the string
"Hello world!" when run in Script Editor:
def run(): return "Hello world!"
This is equivalent to the AppleScript:
on run return "Hello world!" end run
How does PyOSA relate to Appscript?
Appscript is an Apple event bridge, allowing Python scripts to send Apple events to applications. That's great when you want to control one process from another, but no help if you need a script that can call and/or be called by by its host process ("attachability"). For that level of integration/interaction, you need a full OSA language.
PyOSA packages the Python interpreter as an OSA language component, allowing Python scripts to be attached to any OSA-aware application. It also integrates fully with appscript, allowing PyOSA scripts to send Apple events directly to the host process and vice-versa. This is essential for tasks like Folder Actions and Mail rules, which can't be done with appscript alone. (Read full description on the developer's website.)
PyOSA requires Mac OS X 10.4 or later and Appscript 0.17.2 or later.