Xorn
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Functions
xorn.guile Namespace Reference

Embedding a Guile interpreter. More...

Classes

class  GuileError
 Raised on Guile-related errors. More...
 
class  Procedure
 Guile procedure. More...
 

Functions

def lookup
 Return the variable bound to a symbol. More...
 
def define
 Create a top level variable. More...
 
def load
 Load a file and evaluate its contents in the top-level environment. More...
 
def eval_string
 Parse a string as Scheme and evaluate the expressions it contains, in order, returning the last expression. More...
 

Detailed Description

Embedding a Guile interpreter.

This module allows embedding a Guile interpreter into a Python application. It translates Python objects transparently into Guile objects and vice versa. In order to make a Python function available to Guile code, just bind it to a variable name:

1 def add(x, y):
2  return x + y
3 
4 xorn.guile.define('add', add)
5 xorn.guile.eval_string('(add 1 2)') # => 3
6 xorn.guile.eval_string('(add 1.0 2.0)') # => 3.0

Function Documentation

def xorn.guile.define (   name,
  value 
)

Create a top level variable.

If the named variable already exists, just changes its value.

Exceptions
GuileErrorif value can't be represented as a Guile object

Definition at line 68 of file guile.py.

def xorn.guile.eval_string (   string)

Parse a string as Scheme and evaluate the expressions it contains, in order, returning the last expression.

Definition at line 87 of file guile.py.

def xorn.guile.load (   name)

Load a file and evaluate its contents in the top-level environment.

name must either be a full pathname or be a pathname relative to the current directory. If the Guile variable %load-hook is defined, the procedure to which it is bound will be called before any code is loaded.

See also
Guile documentation for %load-hook

Definition at line 81 of file guile.py.

def xorn.guile.lookup (   name)

Return the variable bound to a symbol.

Signals an error if there is no such binding or the symbol is not bound to a variable.

Definition at line 58 of file guile.py.