When you use COM clients such as Excel from Python, you can employ the same debugging techniques as for any Python code; you are simply calling Python objects. However, when you implement COM objects in Python, things become more difficult. In this case, the caller of your Python code isn’t Python, but another application, such as Visual Basic or Delphi. These applications obviously have no concept of a Python exception or a Python traceback, so finding bugs in your Python code can be a problem.
In a nutshell: register your COM objects using
debug on the
command line. Then use the Trace Collector
Debugging Tool item on the PythonWin Tools menu to see any print
statements or Python exceptions. The rest of this section is devoted
to how this works.
To assist with the debugging problem, the Python COM framework has
the concept of a
A dispatcher is similar to a policy object, but dispatches calls to
the policy. The
package provides a number of useful dispatchers.
When you register the COM Server with
--debug (note the double hyphen), the registration
mechanism also registers a dispatcher for your object. The default
dispatcher is known as
although you can specify a
different dispatcher using the
_reg_debug_dispatcher_spec_ attribute on your
object, as described in the earlier section Registering Your COM Server.
DispatcherWin32trace uses the
module to display its output. To see the output ...