Is there a JavaScript (ECMAScript) implementation written in Python?
Are there any JavaScript (ECMAScript) implementations wr开发者_如何学JAVAitten in pure Python? It is okay even if its implementation is very slow.
Doesn't seem to be under active development anymore but you could check out pynarcissus
, http://code.google.com/p/pynarcissus/source/browse/trunk/jsparser.py
Seems like a binding to V8 (JavaScript interpreter in Google Chromium) is available also, http://www.advogato.org/article/985.html
There is one, of an unknown level of completeness, written in RPython (a subset of Python, that is to say, it runs as normal Python): https://bitbucket.org/pypy/lang-js/overview
You may want to take a look at pydermonkey or python-spidermonkey, both of which, I believe, are python implementations of the Mozilla javascript interpreter.
I would recommend that you just stick to node.js on your local development box, translate your CoffeeScript files over to JavaScript, and deploy the translated scripts with your apps.
I get that you want to avoid having node.js on your servers, that's all fair and good. Jumping through hoops with Python invoking JavaScript to translate CoffeeScript seems more hassle to me than it's worth.
I created Jispy to embed JS in Python.
From the docs:
A JavaScript Interpreter In Python
Jispy is an interpreter for a strict subset of JavaScript, fondly called LittleJ (LJ). It employs recursive descent for parsing and is very easily extendable.
Built for embedding JavaScript
Jispy's original vision was to seamlessly allow embedding JavaScript programs in Python projects. By default, it doesn't expose the host's file system or any other sensitive element. Some checks on infinite looping and infinite recursion are provided to tackle possibly malicious code.
It comes with an interactive console, so you can get up and running in no time.
Hope this helps.
Have you heard of PyV8? It's a Python wrapper of Google's V8 JavaScript engine. It may be what you're looking for.
精彩评论