If you have 2 nodes at the same position, comparing them like node1 == node2 surprisingly returns True. Moreover, checking node1 in list_ returns True if the list_ only has node2. I hope this is not intentional ![]()
Doing == means “equal”. If you need to check if is actually the node, use node1 is node2.
Doing node1 in list_ means it compares the object with ==: 6. Expressions — Python 3.14.0 documentation
to check if the actual object is in the list, you can do:
if any(node1 is e for e in _list):
Thank you! Right, but isn’t it subjectively selective to consider them equal based on position and type? Why is it not based only on type then, or why does it ignore different indexes and parents? It seems to me like a more specific equality check would be more expected and readable — node in otherPath.nodes returning True just doesn’t seem intuitive. And any exact attributes can still be explicitly compared one by one as needed.
The equal method does compare all relevant properties. But not node.parent. So a smooth node is not equal a corner node.
And the behavior of the python in clause is indeed not very intuitive. But for most basic types it des make sense to check equality (e.g. for strings or numbers).