Web Browser Programming in Python
TODO: merge in and research these, found on comp.lang.python
Yes, Python can do it... on Windows.
Two (examples) ways:
ActiveScripting (PythonScript), included in PyWin32
Gestalt (who mix Python, Ruby & JavaScript, via Silverlight)
TODO: Add mention of IPython Notebook which can be run remotely, easily on AWS, and used within your browser. The HTML client can also interact with JavaScript and DOM, though this feature isn't quite merged yet. There's a lot being done on it, but it's already being used and probably should be mentioned here.
This topic covers ways in which python can be used in web browsers to control, create or manipulate the content within a user's web browser, or a web-based technology (such as WebKit, the technology behind Safari, Midori, the OLPC Browser, Adobe AIR, Google Chrome and much more; XULrunner (the engine behind Firefox and much more); MSHTML (the engine behind IE and much more); and KDE's KHTMLPart.
To clarify what type of technology goes onto this page, some examples of types of technology that can and cannot be added to this section:
Specifically excluded from the list is technology that simply generates static HTML content. So, an HTML pretty-printer library, as the resultant HTML simply uses the browser for "display" purposes rather than using the browser as an "application execution environment", is out. Such technologies can instead be found at WebClientProgramming.
Plugins for Web Browsers that provide direct access to the DOM model of the web browser. In exactly the same way that most web browsers have JavaScript by default as a language that can directly access the DOM model of the web browser, a plugin or other system that can do the same thing (with Python using <script type="text/python" /> instead of JavaScript using <script language="javascript" />) should be listed on this page.
Python-based technology that auto-generates or compiles JavaScript definitely counts, as the resultant JavaScript would be executed by the web browser.
Technology that simply uses JavaScript or depends on JavaScript libraries (such as mochikit, extjs or prototype) does not count, but a Python-based wrapper library around a JavaScript engine definitely counts.
This latter example requires some further explanation: Pyjamas, for example, is a Python-to-JavaScript compiler that can include inline JavaScript. So, although the input to Pyjamas is part Python, part JavaScript, the output is pure JavaScript that runs in a web browser, and so any such "mixed" language libraries should be included on this page.
Python-to-JavaScript Compilers
These are tools that convert Python into JavaScript, that can then be run either stand-alone, using technology such as Spidermonkey, Google's V8 engine (for example, using pyv8), or in a web browser (where, in order to be useful, the applications must of course interface with the DOM model of the browser, typically using an AJAX library).
The translation from Python to Javascript can be done by a Python program
Pyjaco, the Python-to-Javascript Compiler is a python-based compiler that will compile most python code into fairly compact javascript. It uses a small (~60KB) standard library to implement all the usual python types like list, dict, int, bool, etc. It supports classes, inheritance, keyword and variable arguments, and much more. It has a comprehensive test suite, and aims to be the most fun and efficient way to create web applications with Python.
Pyjamas is a Python-to-JavaScript compiler and AJAX-based Web Toolkit and Framework that allows users to write code in standard Python that will be run in a web browser, after translation to JavaScript. pyjs - the compiler - can also be used as a stand-alone JavaScript compiler. There are three main modes: --strict, providing as close to full strict python compatibility and interoperability as is both possible and has been contributed so far (which is quite a lot); -O, providing a subset of python functionality and providing much faster performance as a result; --stupid-mode which falls back to javascript for certain operations, with the result that the output is much easier to read and to compare to the original python from which it was generated, but runs the risk of changing the meaning of the python application and requiring a deep understanding of how javascript operates (stupidly - hence the name of the mode).
Py2Js is an unmaintained project that can still be downloaded here. It is purely a Python-to-JavaScript compiler/translator.
Py2js is a maintained project that provides a Python-to-JavaScript compiler.
PyCow is an unmaintained project to translate Python code to Javascript with Mootools
Fiddle Salad is a web development IDE with HTML and CSS that compiles Python to JavaScript
Transcrypt is a new tool, intended for professional use, to precompile Python 3.6 into compact, readable JavaScript. It allows for seamless integration with any JavaScript library without gluecode or dataconversion. Compact downloads, kB's rather than MB's, runtine only 20kB. Load and execution speed the same as JavaScript. You can debug your application from the Python sourcecode, even it it's minified. Optional static typechecking and linting included. Possibility to embed JSX into the sourcecode for use with React. Documentation with extensive examples using a diversity of JavaScript libraries. Native JavaScript code can be inserted anywhere in the Python source. Can be used in combination with Django or Bottle to have the same language on client and server side. Many demo's are part of the distribution, including an iOS web app. Transcrypt can be pip-installed from PyPi
