От: | Аноним | ||
Дата: | 21.01.09 09:44 | ||
Оценка: |
objects of different types always compare unequal,
and are ordered consistently but arbitrarily.
,и ещё:x==y calls x.__eq__(y)
Кому же все-таки верить? Для проверки я создал класс:There are no swapped-argument versions of these methods
(to be used when the left argument does not support the operation
but the right argument does)
class TypeControlCompare:
'''compare two values and check the type
'''
def __init__(self,value_expected,type_expected):
self.__value_expected=value_expected
self.__type_expected=type_expected
def __eq__(self,value):
return (value==self.__value_expected)and(isinstance(value,self.__type_expected))