Python COM object: attribute value typing

Steve Holden sholden at holdenweb.com
Thu Jan 24 02:10:49 CET 2002


"Mark Hammond" <mhammond at skippinet.com.au> wrote ...
> Steve Holden wrote:
> > Quite an odd one, this. I'm creating a COM object in Python and
accessing it
> > from VBscript. I set a value true/false with the following statement in
the
> > COM object:
> >
> >     self.AVS_aok = (r in "23")
> >
> > AVS_aok is to be found in both _public_attrs_ and _readonly_attrs_, if
it
> > matters. When I access this attribute from VBscript it comes back with
> > TypeName "Boolean", and values True/False, where I would have expected a
> > simple 1 or 0.
> >
> > I would not have though that Python retained anything other than the 0
or 1
> > result. How can this be?
>
> Python has internal PyTrue and PyFalse objects.  boolean expressions
> will return one of these objects, rather than the simple 1 and 0
> objects.  Even though they are both integers, PythonCOM can still make
> the distinction.
>
> ie:
>  >>> true=(1==1)
>  >>> true==1
> 1
>  >>> true is 1
> 0
>  >>>
>
> PythonCOM explicitly creates a VT_BOOL variant when it sees either
> PyTrue or PyFalse.

Thanks. I should have guessed (or used the source, Luke).

regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list