Say I want to compare 2 variables with different data types: string and int. I have tested it both in Python 2.7.3 and Python 3.2.3 and neither throws exception. The result
def isEqual(a, b):
if not isinstance(a, type(b)): raise TypeError('a and b must be of same type')
return a == b # only executed if an error is not raised