PySWIP enables querying SWI-Prolog in your Python programs.
Project description
PySWIP is a GPL’d Python - SWI-Prolog bridge which enables querying SWI-Prolog in your Python programs.
PySWIP includes both an (incomplete) SWI-Prolog foreign language interface and a utity class that makes it easy querying SWI-Python.
- Example:
>>> from pyswip.util import Prolog >>> prolog = Prolog() >>> prolog.assertz("father(michael,john)") [{}] >>> prolog.assertz("father(michael,gina)") [{}] >>> list(prolog.query("father(michael,X)")) [{'X': 'john'}, {'X': 'gina'}] >>> for soln in prolog.query("father(X,Y)"): ... print soln["X"], "is the father of", soln["Y"] ... michael is the father of john michael is the father of gina