Python bindings ############### .. highlight:: python .. testsetup:: import sys Cf0x10 programs may be easily invoked from Python: .. doctest:: >>> from cf0x10.interpreter import Program >>> >>> p = Program('"Hello, world"') >>> p.execute(sys.stdin, sys.stdout, []) Hello, world In your Python program, just decorate functions with ``@comefrom`` to make them eligible jump targets from Cf0x10 programs: .. doctest:: >>> from cf0x10.bindings import comefrom >>> >>> @comefrom('if who') ... def cf_greeting(io, scope): ... io.stdout.write("Hello, %s" % scope['who']) >>> >>> p = Program('who = "world"', additional_bindings=[cf_greeting]) >>> p.execute(sys.stdin, sys.stdout, []) Hello, world .. automodule:: cf0x10.bindings :members: .. highlight:: default