Brython (Browser Python) is an implementation of Python 3 running in the browser, with an interface to the DOM elements and events.
Here is a simple example of an HTML page running Python:
To use Brython, all there is to do is:
- Load the script brython.js. If you want to use modules from the standard library, also load brython_stdlib.js
- Run the function
brython()on page load, like
- Write Python code inside tags
<script type="text/python">or linking it.
Brython supports most of the syntax of Python 3, including comprehensions, generators, metaclasses, imports, etc. and many modules of the CPython distribution.
Test Brython online
If you want to test Brython online you can visit the following:
Gallery of examples
Curious about how Brython works ?
Community (questions, feedback, issues, new features, ...)
There is a main mailing list in English.
If you find a bug/issue or do you want to see a new feature in Brython, please, open a new issue.