importing dlls with python

Michael Kelly mkelly2002NOSPAM at earthlink.net
Wed Feb 20 21:57:52 CET 2002


On 19 Feb 2002 20:29:07 -0800, tkeon0 at netscape.net (Trevor Keon)
wrote:

>Hi, I am new to Python, and was wondering if it was possible to import
>dlls written in Delphi 5?  I have tried a number of methods to make it
>work, and I either get:

[snip]

Hi Trevor.  If you can get by using all Automation Compatible
types in your exported function params and returns then you
can very easily use a COM dll in Python.  If you make the dll
an Automation Library with dual-interface IDispath interface
(the default used by Delphi 5 when making an Automation
Library) then you can make it into a module using Makepy
and just import the module.  To get an instance of the
COM class you just assign the CoClass to a variable as
in:

#assuming you use -o switch in Makeypy to
#create module mymodule.py
#then look in mymodule.py and
#see what the CoClass name is, then:

from mymodule import *

myCoClass = CoClassName()
myResult = myCoClass.SomeMethod(SomeParam)

It's very quick esp. in D5(which is what I use to create most
of my COM and ActiveX stuff.)

The other consideration could be speed if you are
making like 10,000 calls into your dll code per loop
or something like that.


--

"I don't want to belong to any club that would have me as a member."
    -- Groucho Marx



More information about the Python-list mailing list