@runpython directive

The @runpython(x) directive macro expands x then runs it under the python interpreter. The directive itself is stripped from the generated output. i.e. it macro expands into nothing. The purpose is normally to allow for definitions of functions and variables and so forth within the python interpreter, ready for subsequent use by the @defpython directive.


@runpython
{
    # This is python!
    # Fibonacci series:
    # the sum of two elements
    # defines the next
    def getfibnumbers(max):
        a,b = 0,1
        s = []
        while b < max:
            s.append(b)
            a,b = b,a+b
        return s
}