Python in a COM?

Alex Martelli aleaxit at yahoo.com
Tue Jan 23 07:34:16 EST 2001


"Mitja Semolic" <mitjase at hotmail.com> wrote in message
news:pIcb6.714$6a.35057 at news.siol.net...
> Instead of using the pythonxx.dll is there a python implemented in COM
> object?

Python can implement COM objects, but not "instead of"
python20.dll etc -- the COM interfaces are built "on
top of" python20.dll (by .pyd python-extension DLL's).

Still, this is a deployment detail.  If you for
example instantiate a Microsoft Script-Control OCX
(progid "ScriptControl") and set its Language property
to the string "Python" (on a Win32 machine where
Python AND the win32all extensions are installed
correctly; e.g., an ActiveState Python build for
Win32 does that for you), you'll get a usable COM
(ActiveScripting) instance of Python (you can now
pump source code into it with AddCode, evaluate
expressions, execute statements, ..., all with the
suitable methods of ScriptControl).

This, for example, offers the easiest way to get a
Python interpreter instance up for use from an
application written in (e.g.) Visual Basic, Delphi,
etc (so you can _script_ in Python, no matter what
language most of your code is in; of course, you'll
also have to _expose_ any 'callbacks', that the script
may make into your application-code, as a COM object
model of the application [and use AddObject] -- that
is part of the game of using ActiveScripting).


Why do you care if the various DLL's that come up
when you do that are all "COM objects", or pull up
other non-COM DLL's (such as python20.dll) in their
turn?  After all, most "COM objects" you use _do_
in turn use some non-COM DLL's (MSVCRT.DLL, the MFC
ones, the Delphi ones, the VB ones, depending) --
and yet you don't really care much about that.


Alex






More information about the Python-list mailing list