Python and COM - Blowing the others away

Python COM Extensions Readme

This is the readme for win32com. Please check out the win32com documentation index

The win32com/test directory contains some interesting scripts (and a new readme.txt). Although these are used for testing, they do show a variety of COM techniques.

Important Currency changes

In all builds prior to 204, a COM currency value was returned as a tuple of integers. Working with 2 integers to represent a currency object was a poor choice, but the alternative was never clear. Now Python ships with the decimal module, the alternative has arrived!

To ease the transition, from pywin32 build 205 a FutureWarning will be issued when your code fetches a COM currency object - but a tuple will still be returned. However, if your code sets pythoncom.__future_currency__ = True, a warning will not be issued, and a decimal module object will be returned. At some undetermined point in the future (but not before build 208) the new behaviour will be the default.

When supplying a COM currency object, you can supply either a decimal object or a tuple. This issue only applies when pythoncom passes you a currency value

Python 2.3 does not ship with a decimal module. For this reason, win32com/decimal_23.py is supplied with pywin32. This is a clone of the decimal module, but will only be used when import decimal fails. If you want to use this functionality in your Python 2.3 programs, you should write something similar to:

    try:
        import decimal
    except ImportError:
        import win32com.decimal_23 as decimal
    val = decimal.Decimal("123.45")

Recent Changes

win32com.shell

The shell interfaces have undergone a number of enhancements and changes. A couple of methods have changed signature between the first build with shell support (200) and later builds. SHGetFileInfo was broken in its result handling, so had to be changed - this is the only function used by the samples that changed, but others not used by the samples also have changed. These shell interfaces are now generally stable.

New win32com.taskscheduler module

Roger Upole has contributed an interface to the Windows task scheduler. This is actually very neat, and it allows Python to edit the task list as shown by Windows Control Panel. Property page suppport may even appear later, now that the win32 library has the new win32rcparser module.

ActiveX Scripting

Python only supports "trusted" execution hosts - thus, it will no longer work as an engine inside IE (Python itself no longer has a restricted execution environment). Python continues to work fine as an Active Scripting Engine in all other applications, including Windows Scripting Host, and ASP.

There is also support for Python as an ActiveX Scripting Host.

Active Debugging seems to be fully functional.

Older stuff