Created: 2008-11-19 08:51
Updated: 2018-08-15 15:09

Psil - Python S-expression Intermediate Language

Greg Hewgill

Psil is a Lisp family language designed for close integration with Python.


Psil requires Python 3.1 or later.


To run a REPL (interactive read-eval-print-loop):

$ python3.1
PSIL interactive mode
Use (quit) to exit

To run a Psil script in a file:

$ python3.1 hello.psil
hello world

or (on Unix-like systems):

$ ./hello.psil
hello world

To run Psil code from within Python:

#!/usr/bin/env python3.1

from psil.interpreter import psil

square = psil("""
    (lambda (x)
        (* x x))


A slightly more advanced example where the glob=globals() is needed so that the Psil code can see back into the Python module for the fact function:

#!/usr/bin/env python3.1

from psil.interpreter import psil

fact = psil("""
    (lambda (x)
      (if (== x 0)
          (* x (fact (- x 1)))))
""", glob=globals())


The psil.test file is a doctest module with many examples including macros. To run the tests:

$ python3.1 --test
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more