Why doesn't default property invoke for if statement?
Duffy O'Craven
dufw1 at quinda.com
Wed Dec 12 11:02:49 EST 2001
When using my component, I am hoping to avoid making script writing
error-prone. So I want to require exactly the same expression for print as
for anywhere else in the script. But I am also hoping that reference to an
object, which in many contexts is just a boolean, can use the default
binding id(0) aspect of COM. Unfortunately
if Trans.Status.Value:
print Trans.Status
print "case 2",
if 0 != Trans.Status:
print Trans.Status
print "case 3",
if Trans.Status:
print Trans.Status
prints
case 2 0
case 3 0
I think that print Trans.Status
invokes the default property of Status, which is Status.Value, but
I think that if Trans.Status:
does not.
Status is of type
interface IEnum : IDispatch
{
[propget, id(1), helpstring("property Text")] HRESULT Text([out, retval]
BSTR *pVal);
[propput, id(1), helpstring("property Text")] HRESULT Text([in] BSTR
newVal);
[propget, id(0), helpstring("property Value")] HRESULT Value([out, retval]
long *pVal);
[propput, id(0), helpstring("property Value")] HRESULT Value([in] long
newVal);
};
an excerpt of the the type of Trans is:
interface ITransaction : IDispatch
{
[propget, id(5), helpstring("property Status")] HRESULT Status([out,
retval] IEnum* *pVal);
};
Why doesn't the default binding property invoke for if statement? Can I
achieve my goal of exactly the same expression for print as for anywhere
else in the script?
- Duffy O'Craven
More information about the Python-list
mailing list