爲什麼我不能重新定義__and__
運算符?重新定義__and__運算符
class Cut(object):
def __init__(self, cut):
self.cut = cut
def __and__(self, other):
return Cut("(" + self.cut + ") && (" + other.cut + ")")
a = Cut("a>0")
b = Cut("b>0")
c = a and b
print c.cut()
我想(a>0) && (b>0)
,但我得到了B,那的and
B =切( 「B> 0」),應切斷(大寫) – joaquin 2010-04-19 15:35:21