Busy making things: github, links, photos, @mc.

PyCon: Scripting the Mac with Python

Posted: March 23rd, 2005 | Author: | Filed under: Apple, Python | 10 Comments »

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.


10 Comments on “PyCon: Scripting the Mac with Python”

  1. 1 Jacob Kaplan-Moss said at 10:11 am on March 25th, 2005:

    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 said at 4:48 pm on March 25th, 2005:

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

  3. 3 Matt Croydon said at 9:35 am on March 26th, 2005:

    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 said at 11:53 am on March 28th, 2005:

    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 said at 3:03 pm on March 28th, 2005:

    Hey guys –

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

    Jacob

  6. 6 ee211f47473c said at 7:51 am on May 15th, 2008:

    ee211f47473c…

    ee211f47473c212fdf88…

  7. 7 propecia said at 4:41 pm on January 24th, 2011:

    This idea has become outdated

  8. 8 vyvoz stroitelnogo musora said at 12:43 pm on February 10th, 2011:

    vyvoz stroitelnogo musora spb…

    vyvoz musora…

  9. 9 Hipolito M. Wiseman said at 7:49 am on February 14th, 2011:

    How did you make this template? I got a blog as well and my template looks kinda bad so people don’t stay on my blog very long :/.

  10. 10 Tory Burch 2011 New Styles said at 10:54 pm on February 14th, 2011:

    tory burch shoe sale …

    Tory Burch flip flop online sale.For the younger working expat women,look at these tory burch Shoes.these tory burch flip flop are definitely fun,yet the glossy design and round-toe stay these lovely.These tory burch shoes with multiple.New arrivel Tor…