The project is still in an experimental stage. There should be unknown bugs and missing components.
(use-modules (python import))
(import http.server)
(import socketserver)
(let* ((handler #.http.server.SimpleHTTPRequestHandler)
(httpd (#.socketserver.TCPServer #("" 8000) handler)))
(#.httpd.serve-forever))
guile-python provides seamless interface to Python from GNU Guile.
- GNU Guile 2.2+
- Python 3.3+
$ ./bootstrap
$ ./configure
$ make
$ sudo make install
guile-python consists of three modules, (python eval)
, (python import)
and (python core)
:
(python eval)
provides a few procedures to run python code given as string.(python import)
providesimport
macro (note that this shadows built-inimport
) and#.
syntax, which allows python-style member accessing.(python core)
is a core module used internally.
Python object is converted to Scheme object according to the following table:
Python | Scheme |
---|---|
Integer | Integer |
Float | Real |
Bytes | Bytevector |
String | String |
List | List |
Tuple | Vector |
Dictionary | Hash table |
True | #t |
False | #f |
None | #nil |
Callable object | Procedure |
Object | Python object (wrapped pointer) |
-
Procedure:python-eval code
Equivelent toeval(code)
in Python. Returns evaluation result. -
Procedure:python-exec code
Equivelent toexec(code)
in Python. Returns#t
.
-
Macro:import module
Equivelent toimport module
in Python. Note that this shadows built-inimport
. -
Reader Extension:#.object.attribute...
Equivelent tofoo.bar...
in Python. The value is automatically converted between Python and Scheme.
Python'sfoo_bar
can be writtenfoo-bar
in Scheme.
TANI Kojiro ([email protected])
guile-python is distributed under GPLv3.