Commits

Pierre Carbonnelle committed 4c75486

small fixes

Comments (0)

Files changed (3)

pyDatalog/examples/SQLAlchemy.py

 print(John.salary_class) # prints 6
 
 # who has a salary of 6300 ?
-X = pyDatalog.Variable()
 Employee.salary[X] == 6300 # notice the similarity to a pyDatalog query
 print(X) # prints [Employee: Mary]
 print(X.v()) # prints Employee:Mary

pyDatalog/examples/python.py

 print(John.salary_class) # prints 6
 
 # who has a salary of 6300 ?
-X = pyDatalog.Variable()
+pyDatalog.create_atoms('X')
 Employee.salary[X] == 6300 # notice the similarity to a pyDatalog query
 print(X) # prints [Mary]
 print(X.v()) # prints Mary

pyDatalog/pyParser.py

     
     def __str__(self):
         """ pretty print the result """
-        if self.data in (True, None): return str(self._data)
+        if self.data in (True, []): return str(self._data)
         # get the widths of each column
         widths = [max(len(str(x)) for x in column) for column in zip(*(self._data))]
+        widths = [max(widths[i], len(str(self.variables[i]))) for i in xrange(len(widths))]
         # get the formating string
         fofo = ' | '.join('%%-%ss' % widths[i] for i in xrange(len(widths)))
         return '\n'.join((fofo % self.variables,