Skip to main content
PySWIP Alt 0.2.3
================


Disclaimer:

This is a fork from https://github.com/yuce/pyswip
Its only purpose is to publish the most updated version at pypi

-----------------

PySWIP is a Python - SWI-Prolog bridge enabling to query SWI-Prolog
in your Python programs. It features an (incomplete) SWI-Prolog foreign
language interface, a utility class that makes it easy querying with Prolog
and also a Pythonic interface.

Since PySWIP uses SWI-Prolog as a shared library and ctypes to access it,
it doesn't require compilation to be installed.

Note that this version of PySWIP is slightly incompatible with 0.1.x versions.

Requirements:
-------------

* Python 2.3 and higher.
* ctypes 1.0 and higher.
* SWI-Prolog 5.6.x and higher (most probably other versions will also work).
* libpl as a shared library.
* Works on Linux and Win (32 & 64), should work for all POSIX.

News
----

* Importing ``pyswip`` automatically initializes SWI-Prolog.
* Fixed a bug with querying lists with the new interface.

Example (Using Prolog):
-----------------------

>>> from pyswip 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

Since version 0.1.3 of PySWIP, it is possible to register a Python function as a
Prolog predicate through SWI-Prolog's foreign language interface.

Example (Foreign Functions):
----------------------------

from pyswip import Prolog, registerForeign

def hello(t):
print "Hello,", t
hello.arity = 1

registerForeign(hello)

prolog = Prolog()
prolog.assertz("father(michael,john)")
prolog.assertz("father(michael,gina)")
list(prolog.query("father(michael,X), hello(X)"))

Outputs:
Hello, john
Hello, gina

Since version 0.2, PySWIP contains a 'Pythonic' interface which allows writing
predicates in pure Python (*Note that interface is experimental.*)

Example (Pythonic interface):
-----------------------------

from pyswip import Functor, Variable, Query

assertz = Functor("assertz", 2)
father = Functor("father", 2)

call(assertz(father("michael","john")))
call(assertz(father("michael","gina")))

X = Variable()
q = Query(father("michael",X))
while q.nextSolution():
print "Hello,", X.value

Outputs:
Hello, john
Hello, gina

Metadata

Release files for pyswip_alt 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyswip_alt 0.2.3
File Size Uploaded Provenance Actions
pyswip_alt-0.2.3.tar.gz 22.1 kB Without provenance Details for pyswip_alt-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyswip_alt 0.2.3
File Interpreter ABI Platform Actions
pyswip_alt-0.2.3-py2-none-any.whl Python 2 none any Details for pyswip_alt-0.2.3-py2-none-any.whl

Total release size: 44.0 kB

Release files / pyswip_alt-0.2.3.tar.gz

Download URL pyswip_alt-0.2.3.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a19172f14a69a6014f966ee9074f6ffbaca991a5084176af60c3559a0c90f685
BLAKE2b-256 checksum
How to use checksums
8f581f1d3b35accd2b8a3208fbcef90b759a6c19f7e070b38fce4031b5238066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyswip_alt-0.2.3-py2-none-any.whl

Download URL pyswip_alt-0.2.3-py2-none-any.whl
Size 21.9 kB
Tags Python 2
SHA-256 checksum
How to use checksums
da6d97afb4d1494a07fe5c434d8f2569f8ead1a9c3fc05cc0f035aba75953ac6
BLAKE2b-256 checksum
How to use checksums
ea52462d1d5945e6494e59dda06aa600e038e81f228229b236231f48e061bf5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyswip_alt 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page