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

Late-Bound Automation

Late-bound automation means that the language doesn’t have advance knowledge of the properties and methods available for the object. When a property or method is referenced, the object is queried for the property or the method, and if the query succeeds, the call can be made. For example, when the language sees code such as:

xl.Visible = 1

the language first queries the xl object to determine if there is a property named Visible, and if so, asks the object to set the value to 1.

By default, the win32com.client package uses late-bound automation when using objects. In the examples we’ve seen so far, the win32com.client package has determined the Visible property is available as you attempt to use it. In the parlance of PythonCOM, this is known as dynamic dispatch .

If you look at the object, Python responds with:

>>> `xl`
<COMObject Excel.Application>

This says there’s a COM object named Excel.Application. Python knows the name Excel.Application from the ProgID that created the object.

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