[Pythonmac-SIG] inputing multi-digit numbers

has hengist.podd at virgin.net
Thu Nov 10 23:34:45 CET 2005


Paul Berkowitz wrote:

>[Excel's scripting interface is] definitely not very "English-like", which AppleScript is meant to be,

The 'English-like' aspect is superficial and somewhat by-the-by; the defining characteristic of the Apple Event Object Model is that it's query-driven. Excel and Word expose conventional OO-style interfaces; everything is done via accessors and iteration and invoking methods on objects one at a time. It's the sort of lower-level API a true AEOM would abstract over, but MS - presumably for reasons of economy - just bridge it directly.


>But the model is definitely more accommodating to VBA, and to
>Python, for that matter, than to normal AppleScript,

Python has no technical issues with the AEOM. One problem that does occur is that most Python users aren't familiar with the AEOM, so they look at some appscript code and because it uses OO-like syntax they assume it will behave according to OO rules too, which it doesn't. For the latest release I've added a couple chapters to the manual that explain all this stuff in some detail, so hopefully there'll be less of this confusion in future.


>since it was designed
>for a language where you can specify the arguments of a method explicitly by
>naming both the arguments (keys) and values rather than just have them all
>run on like AppleScript does it.

Don't really follow you here, unless you mean that Excel doesn't use whitespace in its keywords. (AS-style keywords are a non-issue for Python, etc. anyway, since it's easy to transform them automatically to C-style identifiers.)


> > I cede to your knowledge about the specifics of this, as I do very
>> little with Excel from AS, and am still using v. X. I stand corrected in
>> particular on driving it from Python via appscript.
>
>It would certainly be "interesting" - but can be done.

Sure - errors and omissions excepted. I've done some minor tests and shaken out a couple 'issues' so far, as Excel is one of those odd corner cases that's good for flushing out subtle incompatibilities with AppleScript. It's been a bit of a PITA determining where appscript's tolerance of other parties' rank stupidity should begin and end. AppleScript's merry acceptance of all kinds of weird slop masks a whole bunch of application sins, and Apple don't set down sufficiently rigorous specifications for application and AE bridge developers to avoid creating/being caught out by them. I try to resolve these as I find them/they're reported, but you never know for sure; application developers can be awfully creative. So if you do run into any problems, let me know of them.

Currently there are a couple caveats I'm aware of:

1. Excel defines 'Get' and 'Set' commands in its dictionary, but these do not work correctly. Use 'get' and 'set' instead (appscript defines these as standard since so many applications don't).

2. htmldoc re-formats direct parameters of type 'reference'; this omits some description info that might be of use and fails to indicate when a direct parameter is optional (there are bugs filed on this, but I've yet to figure out the best solution)


If someone (Paul, maybe?) wants to send me some non-trivial AppleScripts and test data that will work on Excel X (I don't have 2004), I'll be happy to port them to Python and see how they fare.

has
-- 
http://freespace.virgin.net/hamish.sanderson/


More information about the Pythonmac-SIG mailing list