Pure Python JavaScript Translator/Interpreter
Everything is done in 100% pure Python so it's extremely easy to install and use. Supports Python 2 & 3. Full support for ECMAScript 5.1, ECMA 6 support is still experimental.
Simple Example:
>>> import js2py
>>> js2py.eval_js('console.log( "Hello World!" )')
'Hello World!'
>>> add = js2py.eval_js('function add(a, b) {return a + b}')
>>> add(1, 2) + 3
6
>>> add.constructor
function Function() { [python code] }
>>> js2py.require('underscore')
'function _(obj) { [python code] }'
You can also import a big number of node modules as if they were written in Python! For example, here we import a pure JS library crypto-js:
>>> CryptoJS = js2py.require('crypto-js')
>>> data = [{'id': 1}, {'id': 2}]
>>> JSON = js2py.eval_js('JSON')
>>> ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123')
>>> bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123')
>>> decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)).to_list()
>>> decryptedData
[{u'id': 1}, {u'id': 2}]
Now also supports JavaScript 6 (still experimental):
>>> js2py.eval