- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
class GovnoClass(object):
def __init__(self, khooj, pizda, djigurda):
self.khooj = khooj
self.pizda = pizda
self.djigurda = djigurda
def __eq__(self, right):
return (self.khooj , self.pizda, self.djigurda ) == right
a = GovnoClass(1,4,88)
b = GovnoClass(1,4,88)
print a==b
По кочану: http://ideone.com/XTFmRZ
В доке по питону насчет этого есть вот такая мутная фраза: 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); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection.
дык, проверяй через is тогда.
http://ideone.com/6B6ANN