run python nodejs code example
Example 1: how to make a python node
class Node:
def __init__(self, value, link_node=None):
self.value = value
self.link_node = link_node
def set_link_node(self, link_node):
self.link_node = link_node
def get_link_node(self):
return self.link_node
def get_value(self):
return self.value
Example 2: python run javascript
import js2py
js = """
function escramble_758(){
var a,b,c
a='+1 '
b='84-'
a+='425-'
b+='7450'
c='9'
document.write(a+c+b)
}
escramble_758()
""".replace("document.write", "return ")
result = js2py.eval_js(js) # executing JavaScript and converting the result to python string