Commits

Pierre Carbonnelle committed f811375

2 fixes for Python 3

Comments (0)

Files changed (2)

pyDatalog/pyDatalog.py

                 return result[0][-1] if result else None                    
             raise AttributeError
         cls.__getattr__ = _getattr   
+
+        def __lt__(self, other): # needed for sorting in aggregate functions using Python 3
+            return id(self) < id(other)
+        cls.__lt__ = __lt__    
     
     def __getattr__(cls, method):
         """

pyDatalog/pyEngine.py

     def __init__(self):
         self.key = ('f', Fresh_var.counter.next()) #id
     
+    def __hash__(self): # needed for Python 3
+        return id(self.key) # id() is fastest
+
     def is_const(self):
         return False
     def get_tag(self, env): #id