Women in Technology

Hear us Roar



Article:
  Using Python and AppleScript Together
Subject:   Shorter alias
Date:   2007-05-10 08:48:18
From:   ulrichp
Instead of


alias ose='open /Applications/AppleScript/Script\ Editor.app/'


Wouldn't it be easier to use


alias ose='open -a "Script Editor"'


Then it doesn't really matter where Script Editor is located at; I'm pretty sure 'open -a' works on stuff not directly in the root of the /Applications folder.


Granted, it's probably six of one, half dozen of another, since I doubt Apple's likely to move the Script Editor anytime soon.

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Noah Gift photo Shorter alias
    2007-05-10 09:57:22  Noah Gift | O'Reilly AuthorO'Reilly Blogger [View]

    I have been abducted by python brainwashing experts and now I always am forced to use the zen of python in everything I do.

    I personally like to be explicit as much as possible, but I also like the short cut way too.
    • the zen of python...
      2007-05-11 06:50:44  airdrummer [View]

      also requires the reduction of redundancy: instead of repeating

      app(u'/Applications/DiskWarrior.app')...

      u should declare a variable:

      dw=app('DiskWarrior')
      dw.activate(timeout=3600)
      dw.disk['main'].rebuild(replacing=k.yes_,
      timeout=3600)
      dw.quit(timeout=3600)

      • Noah Gift photo the zen of python...
        2007-05-11 06:59:00  Noah Gift | O'Reilly AuthorO'Reilly Blogger [View]

        That code does look better. Good suggestion! DRY.