Tim Roberts <timr <at> probo.com> writes:
> Right.  They are two separate Python objects.
> 
>     print table
>     print same_table
>     print table is same_table
> 
> "is" will obviously fail, because it is checking for two identical
> Python objects.  However, did you try the == operator?  The source code
> seems to imply that the __eq__ operator is delegated to the _oleobj_
> properties, which do know about COM object identity.
> 

> Assuming the straight "==" didn't work, I would think a better way would
> be simply to compare the _oleobj_:
> 
>     if table._oleobj_ == same_table._oleobj_:
> 
> The source code in dynamic.py says the _oleobj_ members know how to
> compare themselves.

Thanks very much, Tim. I feel quite sheepish but didn't consider the == 
operator since I'm so used to using "is" for this purpose with Python 
objects.

Both versions that you suggested do the trick: table==same_table and 
table._oleobj_==same_table._oleobj_

Thanks,
Dan

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to