Brython - Python in the browser

Pierre Quentel pierre.quentel at
Wed Dec 19 19:19:29 CET 2012


The objective of Brython is to replace Javascript by Python as the scripting language for web browsers, making it usable on all terminals including smartphones, tablets, connected TVs, etc. Please forgive the lack of ambition ;-)

The best introduction is to visit the Brython site ( Right click on the page with a clock and take a look at the source code : no Javascript, only Python code inside a tag <script type="text/python">. You will notice the inclusion of a script brython.js in the HEAD section, and a call to the function brython() when the page is loaded : that's all it takes

Brython is both a Python to Javascript translator, and a Python interface to the Document Object Model. For instance, access to a DOM element by its id is done by


where "doc" is a keyword referencing the document. To create an element, for instance an HTML anchor :

doc <= A('Python',href="")

The element is created by a built-in class called A, like the HTML tag ; it is inserted in the document by the operator <= which is obviously not "lesser or equal", but an arrow meaning "add child"

Brython is at a very early stage, but already usable : you can visit the gallery with a few applications using Ajax calls, HTML5 local storage, drag and drop, canvas etc. The performance is below pure Javascript, but not by far : the 3D demo is almost as fluid as its Javascript equivalent

It still lacks important features of Python, mostly list comprehensions and classes ; the documentation is limited, there are bugs, the testing process is rudimentary, performance can still improve. For all its current limitations, since I first announced it to a limited audience, the reactions have been very positive (see for instance this blog entry by François Dion :

If you are interested in this project, there are many ways to contribute :
- report bugs or suggest new features on the issue tracker ( : there is a console at to test online, or you can download a local distribution from the development site
- write code : the priority is to extend the built-in Javascript modules (time.js, math.js, etc) - I'm ready to support developers willing to work on this
- contribute to the documentation, translate into other languages, write a tutorial, etc
- promote Brython in forums, blogs, tweets, events, etc
- if you develop demos or apps with Brython, send a link to the community (!forum/brython), it will be added to the gallery on

Enjoy !

More information about the Python-list mailing list