[python-win32] Re: Desire information about Invoke and InvokeTypes

Thomas Heller theller at python.net
Wed Apr 21 07:53:57 EDT 2004


>> I am just thinking that it *could* make more sense (in ctypes.com) to
>> be more explicit.  So the above VB code would translate to
>> ctypes.com:
>>
>> f = whatever.GetField()
>> MessageBox("The field %s has value %d" (field.Item, field.Value))
>
> This will work now, and would be the only way to make it work if you ignored
> the default method/property.  In general, the "default" method/property is
> an alias for an explicit one.

explicit is better than..., but I may not be the VB way.

> But in many respects, the problem is with Python, and the fact it calls
> str() before doing a print.  If you ignore the 'print' issue, it makes
> perfect sense for a Python object wrapping a COM object to provide __str__
> and __int__ overloads when the COM object asserts it provides these
> semantics.  I recall Guido also lamenting the same issue, but his time
> machine failed in that regard.

It seems CDispatch exposes the default method/property via the __call__
mechanism, which is fine.  I'm only wondering why __str__ and __int__
try to use it also.
Anyway, the whole Dispatch stuff seems to do a lot of guesswork
internally.

Probably a lot of (my?) confusion has to do with the fact that VB
doesn't separate properties and methods.

Thomas




More information about the Python-win32 mailing list