Is it possible to integrate Python and JavaScript? For example, imagine you wanted to be able to define classes in JavaScript and use them from Python (or vice versa). If
I was playing with Pyjon some time ago and seems manage to write Javascript's eval directly in Python and ran simple programs... Although it is not complete implementation of JS and rather an experiment. Get it here:
http://code.google.com/p/pyjon/
Here's something, a Python wrapper around the SeaMonkey Javascript interpreter... http://pypi.python.org/pypi/python-spidermonkey
You could also use XPCOM
, say in XUL
based apps like Firefox, Thunderbird or Komodo.
Many of these projects mentioned above are dead or dying, lacking activity and interest from author side. Interesting to follow how this area develops.
For the record, in era of plugin based implementations, KDE camp had an attempt to solve this with plugin and non-language specific way and created the Kross https://en.wikipedia.org/wiki/Kross_(software) - in my understanding it never took off even inside the community itself.
During this chicken and egg -problem time, javascript-based implementions are definately way to go. Maybe in the future we seee pure and clean, full Python support natively in browsers.
There's a bridge based on JavaScriptCore (from WebKit), but it's pretty incomplete: http://code.google.com/p/pyjscore/
If your just interested in sharing complex data types between javascript and python, check out jsonpickle. It wraps the standard Python JSON libraries, but has some smarts in serializing and deserializing Python classes and other data types.
Quite a few Google App Engine projects have used this library. Joose and FirePython both incorporate jsonpickle.