- 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
LispGovno 04.11.2012 21:59 # −4
LispGovno 04.11.2012 22:07 # −3
bormand 04.11.2012 22:28 # +2
По кочану: http://ideone.com/XTFmRZ
LispGovno 04.11.2012 22:54 # −2
bormand 04.11.2012 23:19 # +4
В доке по питону насчет этого есть вот такая мутная фраза: 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.
Fai 05.11.2012 00:32 # +4
anonimb84a2f6fd141 01.04.2013 20:54 # 0
Crazyzubr 05.11.2012 17:31 # +1
дык, проверяй через is тогда.
http://ideone.com/6B6ANN