

def CreateInstance(self, punkouter=None, interface=None, dynamic=False):
    if dynamic:
        if (interface is not None):
            raise ValueError('interface and dynamic are mutually exclusive')
        realInterface = comtypes.automation.IDispatch
    elif (interface is None):
        realInterface = comtypes.IUnknown
    else:
        realInterface = interface
    obj = ctypes.POINTER(realInterface)()
    self.__com_CreateInstance(punkouter, realInterface._iid_, ctypes.byref(obj))
    if dynamic:
        return comtypes.client.dynamic.Dispatch(obj)
    elif (interface is None):
        return comtypes.client.GetBestInterface(obj)
    return obj

dataset/ETHPy150Open enthought/comtypes/comtypes/server/__init__.py IClassFactory.CreateInstance/original