[python-win32] Strange/impossible Python COM interface behavior
mhammond at skippinet.com.au
Fri Jul 6 00:40:39 CEST 2007
> Several things caught my attention about this.
> First, the attempt to print qNode (an object of class
> ent) produces a zero length string. However print of nodes
> for other HTML
> tags such as HTML, BODY, or DIV produces strings that
> describe the object.
Yes - as I mentioned before, str(ob) calls a COM method on 'ob' - so what
'print ob' yields is up to the object, not up to win32com.
> Second, when the INPUT node named 'q' is returned as an item
> in a list (see
> qNode2) printing the list prints the item. I'm not sure
> what's different
> about printing an item in a list vs printing the item, but
> clearly something
> different is involved even though the underlying object is of
> the same type.
This is just Python. When you 'print ob', you are doing, basically, print
str(ob). But when ob is a list, the list object itself uses repr() on the
list elements. So if 'ob' is in a list, you get different results than if
it is not. This is Python, not win32com.
More information about the Python-win32