[python-win32] translating VB into Python...
Michael March
mmarch at gmail.com
Wed May 16 15:58:15 CEST 2007
[resend - I think the mailing list ate my last post..]
See comments below...
On 5/16/07, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > I'm hoping that Mark Hammond will catch sight
> > of this thread and chip in. I'm guessing that
> > you're seeing some odd interaction between
> > the generated class/module and the COM object
> > properties. There's a sort of funniness where
> > properties can be methods... or not.
>
> I'm stumped too.
>
> >
> > Have you generated a proxy module for this?
> > If you haven't use makepy or EnsureDispatch
> > to generate and then look for the definition
> > of the result of the .Field method or
> > property or whatever.
> >
> > I'm groping in the dark a little, but I suspect
> > that the __str__ and __unicode__ magic methods
> > of whatever type that is are actually invoking
> > the default method/property of the underlying
> > object.
>
> This is 1/2 correct - 'print' or 'str' of a COM object will try a default
> method, but this isn't the problem here best I can tell:
>
> From before:
>
> >>> mybug.Field("BG_DESCRIPTION").Value = "123"
> > > Traceback (most recent call last):
> > > File "<stdin>", line 1, in ?
> > > AttributeError: 'unicode' object has no attribute 'Value'
>
> printing repr(mybug) before the above line would be interesting tho, just to
> make sure it is a makepy object - if it wasn't I could see it happening in
> edge cases (ie, the code around ERRORS_BAD_CONTEXT in
> win32com.client.dynamic)
>>> repr(mybug)
'<win32com.gen_py.OTA COM 9.0 Type Library.IBug instance at 0x18853976>'
And here is the generated stub code (in 7zip or uncompressed form.)
http://music.cowmix.com/PythonWin32/
More information about the Python-win32
mailing list