Skip to content

koji-kojiro/guile-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) provides import macro (note that this shadows built-in import) 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 to eval(code) in Python. Returns evaluation result.

  • Procedure:python-exec code
        Equivelent to exec(code) in Python. Returns #t.

Module:(python import)

  • Macro:import module
        Equivelent to import module in Python. Note that this shadows built-in import.

  • Reader Extension:#.object.attribute...
        Equivelent to foo.bar... in Python. The value is automatically converted between Python and Scheme.
        Python's foo_bar can be written foo-bar in Scheme.

Author

TANI Kojiro (kojiro0531@gmail.com)

License

guile-python is distributed under GPLv3.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published