Python and R

Alex Martelli aleaxit at
Fri Sep 1 00:31:15 CEST 2000

"Alex Martelli" <aleaxit at> wrote in message
news:8omh8r0316e at
Summing up: the R com adaptor does not work with
Python; and neither with Visual Basic, when late-bound
(dim sc as Object, then set sc = CreateObject &tc).  A
C-level diagnostic program shows that GetTypeInfo
fails, because "type library not registered".  And my
hypothesis was:

> Haven't looked at the StatConnector sources, yet, but
> I bet I know what's wrong -- confusion around type library
> major/minor codes.  In the IDL, the version is given as
> 0.91; but in the registry, it's registered as "0.5b"; I bet
> this has something to do with it.

...confirmed.  Just setting version(1.0) rather than
version(0.91) for the library statement in the IDL, and
rebuilding/registering the resulting .EXE, now lets it
work just fine with the late-bound VB example, and:

PythonWin 1.6b1 (#0, Aug 23 2000, 13:42:10) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2000 Mark Hammond (MarkH at - see
'Help/About PythonWin' for further copyright information.
>>> from win32com.client import Dispatch
>>> sc=Dispatch("StatConnectorSrv.StatConnector")
>>> sc.Init("R")
>>> sc.Evaluate("2+2")

...with Python just as well.

It's more delicate to keep the tlib version at anything but
1.0 (the IDispatchImpl templates on each ATL class
definition would need explicit major/minor parameters),
while this is a 1-line fix and opens up R interfacing from
any scripting language (Python, Perl, Javascript, ...).  So,
this is what I'd recommend.


More information about the Python-list mailing list