[PYTHONMAC-SIG] Calling any toolbox routine from Python

Guido van Rossum guido@CNRI.Reston.Va.US
Wed, 12 Feb 1997 10:46:16 -0500


> there is a way to make it possible to call *any* toolbox routine from
> Python, at least on PPC and CFM68K. Since the toolboxes are completely
> in shared libraries on those architectures it should be doable to
> create an interface that allows python programmers access to them.
> 
> The interface, however, would be *very* error-prone (no typechecking
> whatsoever) and probably rather convoluted (for instance, I think that
> the only reasonable way to implement return parameters passed by
> address is to pass in an a 1-element array of the right type).
> 
> The advantage, of course, is that I hope everyone on the list will
> quickly create Python wrappers with decent interfaces (and possibly
> type-checking) around their favorite toolboxes and make them
> available.
> 
> The disadvantage, as stated above, is that the interface will be
> clumsy and error-prone, thereby possibly giving MacPython a bad name.
> 
> What do y'all think? If I did the interface, would you use it?

Doesn't Visual Basic have a similar escape into the C world?  I
believe I've seen include files that declared a bunch of entry points
with their address and the type of the arguments.  It seemed obvious
that by specifying the wrong address or type you could blow up the
system but of course the include files that are part of the
distribution can be trusted in the same sense that you can trust
Python extension modules.

Can't you put a little more work in the interface so that this
approach would work?  Then you don't have to provide all the interface
files (though they could possibly be generated by a spin-off from
bgen) but someone else can at least write interface files that will
make it relatively safe to use.  Of course you can't ever hope to make
the type check foolproof, but at least some checks (like nr. of args)
are easy.

For return types I would do the standard python thing -- turn them
into extra return values.

--Guido van Rossum (home page: http://www.python.org/~guido/)

_______________
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
_______________