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.
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