pythonmacossourceforge-appscriptpy-appscript

How to get multiple properties at the same time?


I am using Appscript - a Python interface to AppleScript - in a project of mine that basically gets data from a Mac application.

Here is a sample code:

    asobj = app('Things').to_dos()[0]
    self.id = asobj.id()
    self.name = asobj.name()
    self.status = asobj.status()

Every invocation of the properties (id, name, status) does inter-process call and hence it is slow .. especially when you do the same for thousands of the objects.

Is there a way to get multiple properties at the same time via AppleScript's Python interface (appscript)?


Solution

  • I'm not 100% sure how this would be expressed in Python, but most Applescript objects support a "properties" property which will return a dictionary containing key/value pairs for each of the supported properties of that object. I'm guessing that calling asobj.properties() would return an appropriate data structure from which you can then retrieve any individual properties you want.