[python-win32] Python COM User Defined Types

Mark Hammond mhammond@skippinet.com.au
Wed, 26 Feb 2003 16:45:35 +1100


> How can I create variables in my Python code and use them when calling the
> WriteMsg2 method (below)?

You would write:

    # Create a new structure
    s = win32com.client.Record("StructName", object)

where 'object' is (any) COM object from the library you are using - eg, the
object with the WriteMsg2 method.

> Why do I not get a list of
> available constants when I type "win32com.clients.constants."

These constants are only available once the generated code for the COM
object has been imported.  This is generally done by one of the gencache
modules, or even by normal "Dispatch()", assuming makepy has been run
manually.  ie, the constants will only be available after the object has
been created.

> Typically after
> entering the period at the end of an object I am presented
> with a list of attributes/constants/methods.

Clever, eh? <wink>

> I am concerned by these lines from the file generated by makepy:
> # The following 3 lines may need tweaking for the particular server
> # Candidates are pythoncom.Missing and pythoncom.Empty
> defaultNamedOptArg=pythoncom.Missing
> defaultNamedNotOptArg=pythoncom.Missing
> defaultUnnamedArg=pythoncom.Missing
>
> I do not know what to do about the pythoncom.Missing and pythoncom.Empty
> candidates.  What should be done about them?

Ignore them.  I should remove the generated comment.

> Can I simply create an object of type StackObj like this:
> myStack = StackObj()

Nope - like above.

Mark.