[Pythonmac-SIG] appscript
has
hengist.podd at virgin.net
Sun Oct 17 10:31:32 CEST 2004
Jack Jansen wrote:
>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.
Yep. The shell lacks datatypes: everything basically has to be
handled as strings. Which is fine for Tcl which does this anyway, but
for typed languages like AS and Python it means a lot of work in
converting non-text input and output.
You can also execute OSA scripts (including AppleScript) from Python
using the osax module's runscript() function. This supports non-text
input and output.
Main problem with both approaches: they rely on pre-written
AppleScript scripts, or code generators to generate AS source, to get
anything done. It would be much nicer to write _everything_ in pure
Python - which is what appscript lets you do.
>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.
What Jack says: appscript hooks into the same IAC APIs as AppleScript
uses. (Cuts out the middleman, so to speak.:)
>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;-)
http://freespace.virgin.net/hamish.sanderson/iac_examples/iTunes_albums_to_HTML.html
http://applemods.sourceforge.net/mods/Internet/HTMLTemplate.php
(includes a demo, iTunesToWeb)
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list