Introduction to Brython
Main features : Brython supports most of the syntax of Python3, including comprehensions, generators, metaclasses, imports, etc. and many modules of the CPython distribution.
You can install Brython locally by running the following pip command in the terminal :
pip install brython
You can also use Brython without having to install anything, just by including the Brython scripts from a CDN :
To use Brython, all there is to do is:
- Load the script brython.js.
- Run the function brython() on page load, like <body onload=brython()>.
- Write Python code inside tags <script type=”text/python”> or linking it.
Example 1 : “Hello World !” using Brython”
Example 2 : Create an HTML table using Brython
To create a table, we use the HTML tags : TABLE (the table), TR (a table row), TH (a header cell) and TD (a cell). The table is made of rows, each row is made of cells, the first row is generally made of “header cells” describing the value in the matching column
Example 3 : We can build a table from a list of lists. In this example, we will only show the Python script, the surrounding HTML code will remain the same as in the previous example
Future of Brython :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course