[Pythonmac-SIG] Announce: OSATools

Paul Berkowitz berkowit@silcom.com
Wed, 04 Dec 2002 01:37:34 -0800


On 12/4/02 1:15 AM, "Michael J. Barber" <mjb@uma.pt> wrote:

> On Tuesday, December 3, 2002, at 10:44  PM, Bill Bedford wrote:
> 
> [my example using AE snipped]
>> It seems to me that.....
>> 
>> folderList = ['/Applications', '/Library']
>> countList = []
>> for f in dirFolder:
>> countList.append(len(os.listdir(f)))
>> return countList
>> 
>> Is not only much more succinct, but is much easier to read.
>> 
> That's very true. Not much of an example for how to construct an
> AppleScript-style tell block, though, is it? ;)
> 
> Divorced from a real problem, it's a bit difficult to find a good
> example that is interesting, succinct, and (perhaps most importantly)
> uses an application that everyone has. Any suggestions?


AppleScript will always be more verbose than Python - that's part of its
"English-like syntax". And Perl is more succinct than Python. That's how it
is, and less comprehensible.  Best to use an AS example in an application,
which other languages can't touch. Everyone in OS 10.2 can do this:

--------------

tell application "Address Book"
    set joeBlow to make new person with properties {first name:"Joe", last
name:"Blow"}
    tell joeBlow to make new email at end of emails with properties
{label:"home", value:"jblow@earthlink.com"}
    save addressbook
end tell


----------------

Convert that into Python/OSA.

-- 
Paul Berkowitz