[reposting, since it didn't turn up on c.l.py.announce the first time] http://wwwsearch.sourceforge.net/spidermonkey/ This is the first release. There are known bugs, and interfaces may change. Requires Python 2.3 and spidermonkey 1.5. Currently, Pyrex is required to build it. It should work on any platform where spidermonkey runs. I've only tested on Linux, though. spidermonkey is a Python/JavaScript bridge module, making use of Mozilla's spidermonkey JavaScript implementation. Allows implementation of JavaScript classes, objects and functions in Python, and evaluation and calling of JavaScript scripts and functions respectively. Borrows heavily from Claes Jacobssen's Javascript Perl module, in turn based on Mozilla's 'PerlConnect' Perl binding. See also: PyXPCOM. Example of a few of the features: from spidermonkey import Runtime rt = Runtime() cx = rt.new_context() class foo: def hello(self): print "Hello, JavaScript world!" cx.bind_class(foo, bind_constructor=True) f = cx.eval_script("""var f = new foo(); f.hello(); f; // script return value """) print f # script return value f.hello() def repeat(x): return x*2 cx.bind_callable("repeat", repeat) print cx.eval_script(""" var r = ["foo", {"bar": 2.3, "spam": [1,2,3]}]; repeat(r); """) John
participants (1)
-
jjl@pobox.com