PyCon: Scripting the Mac with Python


Posted

in

,

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.

Comments

10 responses to “PyCon: Scripting the Mac with Python”

  1. Jacob Kaplan-Moss Avatar

    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. Jim Reese Avatar

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

  3. Matt Croydon Avatar

    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. Brad Crittenden Avatar
    Brad Crittenden

    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. ee211f47473c…

    ee211f47473c212fdf88…

  6. propecia Avatar

    This idea has become outdated

  7. vyvoz stroitelnogo musora spb…

    vyvoz musora…

  8. Hipolito M. Wiseman Avatar

    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 :/.

  9. 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…