O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required