guile-python
guile-python copied to clipboard
guile-python
WARNING: WIP
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.
Requirements
- GNU Guile 2.2+
- Python 3.3+
Installation
$ ./bootstrap
$ ./configure
$ make
$ sudo make install
Usage
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)providesimportmacro (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) |
Module:(python eval)
-
Procedure:python-eval code
Equivelent toeval(code)in Python. Returns evaluation result. -
Procedure:python-exec code
Equivelent toexec(code)in Python. Returns#t.
Module:(python import)
-
Macro:import module
Equivelent toimport modulein 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_barcan be writtenfoo-barin Scheme.
Author
TANI Kojiro ([email protected])
License
guile-python is distributed under GPLv3.