Skip to main content

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

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page