[XML-SIG] DOM Nodes: Identity test
Andrew M. Kuchling
akuchlin@cnri.reston.va.us
Wed, 24 Mar 1999 09:48:08 -0500 (EST)
Carsten Oberscheid writes:
>What is the "official" way to check if a two DOM Node objects are the same?
>
>The PyDOM implementation, e.g. in the Element.get_parentNode() method, always
>returns a "fresh" Node object encapsulating the real data in a _nodeData object
>(right?), so when I do get_parentNode() twice on the same node, I get two
>different Node objects. Am I supposed to compare the _node members?
I've been wondering about that myself. We don't want to
overload __cmp__ to do this, because Python comparisions are usually
done by value; to check if two objects are the same, you'd use the
'is' operator, but we can't overload that operator. It's probably
best to have a method of Node objects that returns the value of
'self._node is other._node'. Anyone care to suggest a name?
.equals() offers itself, but that may confuse Java users, because
.equals() is by value and == is by identity in Java.
--
A.M. Kuchling http://starship.python.net/crew/amk/
I like to believe it was only the cold that made me shiver, only a strand
of fog in my throat that caused me to catch my breath.
Robert walked away across the moor and I never saw him again. Since that
time I have walked with less comfort in cities.
-- From SANDMAN #51: "A Tale of Two Cities"