Python and COM
The interface between Python and COM consists of two discrete parts:
the pythoncom
Python extension
module and the win32com Python package.
Collectively, they are known as
PythonCOM.
The pythoncom module is primarily responsible for
exposing raw COM interfaces to Python. For many of the standard COM
interfaces, such as IStream or
IDispatch, there is an equivalent Python object
that exposes the interface, in this example, a
PyIStream
and PyIDispatch
object. These objects expose the same methods as the native COM
interfaces they represent, and like COM interfaces, do not support
properties. The pythoncom module also exposes a
number of COM-related functions and constants.
The win32com package is a set of Python source
files that use the pythoncom module to provide
additional services to the Python programmer. As in most Python
packages, win32com has a number of subpackages;
win32com.client
is concerned with supporting
client-side COM (i.e., helping to call COM interfaces), and
win32com.server
is concerned with helping Python
programs use server-side COM (i.e., implement COM interfaces). Each
subpackage contains a set of Python modules that perform various
tasks.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access