为什么我不能重新定义__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