[Pythonmac-SIG] appscript
Jack Jansen
Jack.Jansen at cwi.nl
Sat Oct 16 23:43:48 CEST 2004
On 16 Oct 2004, at 23:13, Kevin Walzer wrote:
> This has brought me, though, to what is perhaps a dumb question: is the
> purpose of appscript to render AppleScript commands in Python syntax?
> I'm a bit confused on this point.
>
> I'm approaching this question from the perspective of Tcl, where it's
> possible to drop into AppleScript directly (if you have the
> TclAppleScript extension installed) using this command/syntax:
>
>
> AppleScript execute {
> tell application "foo"
> do foo
> end tell
> }
>
> One can do something similar in a shell script, if I'm not mistaken,
> via
> osascript (something like <<EOF osascript -"blah blah blah"<<EOF
That's fine for simple scripts, but it breaks as soon as you want to
communicate data. What AppScript does (like gensuitemodule and aeve
before it) is expose the full OSA object model to Python. This allows
you to use the power of Python to do things that are pretty much
impossible in a "little language" like AppleScript.
As a somewhat contrived example (can't think of a non-contrived one
right now:-): think of a script that asks iTunes for the contents of
your music library and formats that as an HTML page. With AppScript and
Python this is probably 20 lines or so. With only a construct like
"AppleScript execute" it'll be much longer due to all the parsing of
the script output you have to do. With standalone AppleScript I don't
even want to ponder the question;-)
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma
Goldman
More information about the Pythonmac-SIG
mailing list