ian-andrich / PythonPengines

A Python interface to the Prolog pengines library. Makes it exceedingly easy to call out to SWI-Prolog within Python!
MIT License
12 stars 9 forks source link

Add a method that returns a generator #14

Closed cmungall closed 5 years ago

cmungall commented 5 years ago

Currently when executing goals that return many results, the Query object will keep accumulating results until all results have been found. There is no way to stream the results.

Ideally we could write:

for r in q.results():
     # do something with r

See https://wiki.python.org/moin/Generators

cmungall commented 5 years ago

oh hold on, I see Query implements __next__, so the query object can act as an iterator, I see

cmungall commented 5 years ago

to properly implement an iterator