- Documentation
- Reference manual
- Packages
- SWI-Prolog Python interface
- library(janus): Call Python from Prolog
- py_version/0
- py_call/1
- py_call/2
- py_call/3
- py_iter/2
- py_iter/3
- py_is_object/1
- py_free/1
- py_with_gil/1
- py_func/3
- py_func/4
- py_dot/4
- py_dot/5
- values/3
- keys/2
- key/2
- items/2
- py_shell/0
- py_pp/1
- py_pp/2
- py_pp/3
- py_obj_dir/2
- py_obj_dict/2
- py_initialize/3
- py_lib_dirs/1
- py_add_lib_dir/1
- py_add_lib_dir/2
- Handling Python errors in Prolog
- Janus and virtual environments (venv)
- library(janus): Call Python from Prolog
- SWI-Prolog Python interface
py_shelljanus as below.
from janus import *
So, we can do
?- py_shell.
...
>>> once("writeln(X)", {"X":"Hello world"})
Hello world
{'truth': True}
If possible, we enable command line editing using the GNU readline library.
When used in an environment where Prolog does not use the file
handles 0,1,2 for the standard streams, e.g., in swipl-win,
Python's I/O is rebound to use Prolog's I/O. This includes Prolog's
command line editor, resulting in a mixed history of Prolog and Pythin
commands.