import spidermonkey rt spidermonkey Runtime cx rt new_context cx execu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
>>> import spidermonkey
>>> rt = spidermonkey.Runtime()
>>> cx = rt.new_context()
>>> cx.execute("var x = 3; x *= 4; x;")
12
>>> class Orange(object):
... def is_ripe(self,arg):
... return "ripe %s" % arg
...
>>> fruit = Orange()
>>> cx.add_global("apple", fruit)
>>> cx.execute('"Show me the " + apple.is_ripe("raisin");')
Show me the ripe raisin