In COM enums are transported as integers and hence hard to use for a programmer, which always has to map these numbers to comprehensive names. Since the enums are only available in typelibraries a wrapper had to be generated (makepy, gencache) to use them. There was no way that a enum could be used dynamically the same way a a COM object. The patch provides a way to use enums dynamically without generating a wrapper. So it is easy to use from a programmers viewpoint. The enum implementation used metaclasses so that the representation of the enum is always in a readable form and the enums are provided via members of enum classes. Used typelibraries are scanned inclusive their dependencies.
>>> from win32com.client import Enums
>>> from win32com.client import Dispatch
>>> Word = Dispatch("Word.Application")
>>> constants = Enums(Word)
>>> print constants.CertificateDetail.certdetIssuer
>>> constants.CertificateDetail.certdetIssuer + 2
This enums class is used for over a year in our Python distribution and tested against Python 2.7.3 and Python 3.2.3
Log in to post a comment.