Source

limpy /

Filename Size Date modified Message
limpy
40 B
419 B
1.4 KB
1.8 KB
433 B

LimPy

Limited Python

LimPy parses a limited version of the Python grammar. It supports most Python syntax except things like class and function definition and trickier things like list and generator comprehensions.

The goal is to be able to expose various Python objects to a scripting environment where non-professional programmers can write simple code to solve various problems.

Origins

LimPy originated in a survey system at YouGov where it gave the users scripting questionnaires the ability to include various bits of Python code that is executed during survey interviews.

A previous version of the survey system allowed Python code but it was not type checked and any bugs only reared their heads at runtime.

LimPy was successful in still offering the power to use Python at runtime but checking types, operations on types and function/method call signatures before runtime to ensure that an entire class of bugs was avoided.

Role

LimPy checks code. You supply it with a namespace of helper objects, another namespace of variables and source code and it will raise various LimPy exceptions if there are problems or return the parsed code and the updated namespace of variables if there were new variables defined in the source.

LimPy does not execute the code. That is up to your runtime system to handle. The returned variables namespace contains only types as values, not real runtime values. Deciding what to do with that namespace is up to your runtime code.

Testing

LimPy has some unit tests. To run them:
% (cd limpy/test && py.test --fulltrace --showlocals --tb=long --verbose)

There should be no test errors or failures.

Changes

1.1

  • LimPy no longer allows assignment to Python reserved words.