PyCon: Scripting the Mac with Python

Before lunch I sat in on a session on using Python to interface with Applescript. Appscript is used to create a bridge between Python code and Applescript. Here’s a quick code snippet to give you an idea what Appscript can do:

from appscript import *
f = app.("Finder.app")
f.help # shows what you can do with it, very nice.
f.desktop.disk[1].free_space.get()
# gives you an insane number of bytes free

Slick indeed. There was also a slick demo to script OmniGraffle to generate a nice looking sitemap using Python, Appscript, and Beautiful Soup. For more cool hacks, check out these examples.

6 Responses to “PyCon: Scripting the Mac with Python”


  1. 1 Jacob Kaplan-Moss Mar 25th, 2005 at 10:11 am

    That script, by the way, is at http://toys.jacobian.org/presentations/2005/appscript/generate-site-map.txt.

    (I’m glad you liked the presentation :)

  2. 2 Jim Reese Mar 25th, 2005 at 4:48 pm

    Is information about the demo using OmniGraffle available anywhere? I’d like to look at that code.

  3. 3 Matt Croydon Mar 26th, 2005 at 9:35 am

    Jim,

    I’m not sure if Jacob Kaplan-Moss is planning on putting his slides online, but you might want to check out his website (http://jacobian.org) or send him an email.

  4. 4 Brad Crittenden Mar 28th, 2005 at 11:53 am

    the example has a few typos in it. this is what worked for me:

    from appscript import *
    f = app("Finder.app")
    f.help() # shows what you can do with it, very nice.
    f.desktop.disk.free_space.get()

  5. 5 Jacob Kaplan-Moss Mar 28th, 2005 at 3:03 pm

    Hey guys –

    The slides are available at http://toys.jacobian.org/presentations/2005/appscript/.

    Jacob

  1. 1 ee211f47473c Trackback on May 15th, 2008 at 7:51 am

Leave a Reply