In [1]:
from flexx.pyscript import py2js, evalpy
In [2]:
js = py2js('for i in range(10): print(i)')
print(js)
In [3]:
def foo(x):
for i in range(x):
print(i**2)
js = py2js(foo)
print(js)
In [4]:
class Bar:
def spam(self):
return 3 + 4
#js = py2js(Bar)
# This only works if Bar is defined in an actual module.
Using evalpy
you can evaluate Python code in NodeJS
In [5]:
evalpy('3*"3"')
Out[5]:
In [ ]: