Is there a way to obtain an exception when the == (equal) operator is used to compare different types? Python 3 throws an exception when attempting to order objects of different types. But == still returns False.
Or is there some other way to avoid hard to detect bugs caused by wrong type assumptions? Are there any design-patterns that could help?
I’m thinking of, e.g., a case where someone uses someone elses implementation of xmlparser.get() which always returns a string, even if the property is basically a number.
No. Because for ==, the reasoning is that equality implies comparibility. If two objects aren’t even comparable they are not equal, therefore it will return false and never throw an exception.