def __le__( self, other ): return self.eval() <= other
def __gt__( self, other ): return self.eval() > other
def __ge__( self, other ): return self.eval() >= other
+ def __hash__(self):return id(self)
+
+def _div(a,b):
+ if isinstance(a,(int,long)) and isinstance(b,(int,long)):
+ if a%b:
+ return a/b
+ else:
+ return a//b
+ else:
+ return a/b
class Binop(Formula):
opmap = { '+': lambda a, b: a + b,
'*': lambda a, b: a * b,
'-': lambda a, b: a - b,
- '/': lambda a, b: a / b,
+ '/': _div,
'//': lambda a, b: a // b,
'**': lambda a, b: a ** b,
'[]': lambda a, b: a[b] ,