{"id":15574604,"url":"https://github.com/tjvr/pyswip","last_synced_at":"2026-04-29T04:01:45.045Z","repository":{"id":22185801,"uuid":"25517858","full_name":"tjvr/pyswip","owner":"tjvr","description":"Use SWI-Prolog from Python. Fork.","archived":false,"fork":false,"pushed_at":"2014-10-21T11:19:47.000Z","size":164,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-30T11:43:27.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://code.google.com/p/pyswip/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tjvr.png","metadata":{"files":{"readme":"README","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-21T11:10:27.000Z","updated_at":"2018-12-07T16:39:51.000Z","dependencies_parsed_at":"2022-08-20T22:41:00.423Z","dependency_job_id":null,"html_url":"https://github.com/tjvr/pyswip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tjvr/pyswip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjvr%2Fpyswip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjvr%2Fpyswip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjvr%2Fpyswip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjvr%2Fpyswip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjvr","download_url":"https://codeload.github.com/tjvr/pyswip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjvr%2Fpyswip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32409944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T03:46:11.172Z","status":"ssl_error","status_checked_at":"2026-04-29T03:37:55.317Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T18:20:01.513Z","updated_at":"2026-04-29T04:01:44.993Z","avatar_url":"https://github.com/tjvr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PySWIP README\n============\n\n:Version: \n\t0.2.2\n\n:Author:\n    Yuce Tekol. \u003cyucetekol@gmail.com\u003e\n\n:Project Website:\n   http://code.google.com/p/pyswip\n    \n\nIntroduction\n------------\n\nPySWIP 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.\n\nSince PySWIP uses SWI-Prolog as a shared library and ctypes to access it, it doesn't require compilation to be installed.\n\nNote that this version of PySWIP is slightly incompatible with 0.1.x versions.\n\nRequirements:\n-------------\n\n* Python 2.3 and higher.\n* ctypes 1.0 and higher.\n* SWI-Prolog 5.6.x and higher (most probably other versions will also work).\n* libpl as a shared library.\n* Works on Linux and Win32, should work for all POSIX.\n\nExample (Using Prolog):\n-----------------------\n\n    \u003e\u003e\u003e from pyswip import Prolog\n    \u003e\u003e\u003e prolog = Prolog()\n    \u003e\u003e\u003e prolog.assertz(\"father(michael,john)\")\n    \u003e\u003e\u003e prolog.assertz(\"father(michael,gina)\")\n    \u003e\u003e\u003e list(prolog.query(\"father(michael,X)\"))\n    [{'X': 'john'}, {'X': 'gina'}]\n    \u003e\u003e\u003e for soln in prolog.query(\"father(X,Y)\"):\n    ...     print soln[\"X\"], \"is the father of\", soln[\"Y\"]\n    ...\n    michael is the father of john\n    michael is the father of gina\n\nSince 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.\n\nExample (Foreign Functions):\n----------------------------\n    \n    from pyswip import Prolog, registerForeign\n\n    def hello(t):\n        print \"Hello,\", t\n    hello.arity = 1\n\n    registerForeign(hello)\n\n    prolog = Prolog()\n    prolog.assertz(\"father(michael,john)\")\n    prolog.assertz(\"father(michael,gina)\")    \n    list(prolog.query(\"father(michael,X), hello(X)\"))\n\nOutputs:\n    Hello, john\n    Hello, gina\n\nSince version 0.2, PySWIP contains a 'Pythonic' interface which allows writing predicates in pure Python (*Note that interface is experimental.*)\n\nExample (Pythonic interface):\n-----------------------------\n\n    from pyswip import Functor, Variable, Query\n\n    assertz = Functor(\"assertz\", 2)\n    father = Functor(\"father\", 2)\n\n    call(assertz(father(\"michael\",\"john\")))\n    call(assertz(father(\"michael\",\"gina\")))\n\n    X = Variable()\n    q = Query(father(\"michael\",X))\n    while q.nextSolution():\n        print \"Hello,\", X.value\n    q.closeQuery()\n\nOutputs:\n    Hello, john\n    Hello, gina\n\nThe core functionality of ``Prolog.query`` is based on Nathan Denny's public domain prolog.py found at http://www.ahsc.arizona.edu/~schcats/projects/docs/prolog-0.2.0.html\t\n\nInstall\n-------\n\nPlease see ``INSTALL`` for detailed instructions.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjvr%2Fpyswip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjvr%2Fpyswip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjvr%2Fpyswip/lists"}