Calico Scheme in Python

Doug Blank doug.blank at
Mon Apr 14 05:52:34 CEST 2014

We are writing to let you know of a recent spin-off from our Scheme
implementation work: we now have a version implemented in Python. This is a
full Scheme with proper tail-call recursion handling written in Python.

We also added some interesting Python-Scheme interactions:

* Scheme can use Python functions and libraries
* You can define Scheme functions for use in Python
* Python's list class serves the role for Scheme's vector class

Some sample uses:

You can just use as a script in Python, IronPython, or

$ python
Calico Scheme, version 3.0.0
Use (exit) to exit
==> (+ 1 1)

This environment has access to Python's built-ins through

==> (sum '(1 2 3))

sum is found in the Python environment.

You can also import and use Python libraries directly:

==> (using "math" "numpy")
(math numpy)
==> (math.sin 3.14)
==> (numpy.array 10)
==> (exit) # or control+d

You can also use calicoscheme inside Python:

$ python
>>> import calicoscheme
>>> calicoscheme.ENVIRONMENT = globals()    # set the environment to the
locals here
>>> calicoscheme.start_rm()
==> (+ 1 1)
==> (define! f (lambda (n) (+ n 1)))     ### define! puts it in the
external env
==> (exit)

And back in Python you can call the define! function using Scheme's

>>> f(100)

You can also call into Scheme like so:

>>> calicoscheme.execute_string_rm("(define x 23)")
>>> calicoscheme.execute_string_rm("x")

To download and get more information, please see:

More information about the Python-announce-list mailing list