Skip to main content

PySWIP enables querying SWI-Prolog in your Python programs.

Project description

PySWIP is a GPL’d Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs.

Example:
>>> from pyswip.util import PrologRunner
>>> prolog = PrologRunner()
>>> prolog.query("assertz(father(michael,john)).")
[{}]
>>> prolog.query("assertz(father(michael,gina)).")
[{}]
>>> prolog.query("father(michael,X).")
[{'X': 'john'}, {'X': 'gina'}]
>>> for soln in prolog.queryGenerator("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