Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brython

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brython

Python 3 in the browser

  • 3.9.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
231
increased by25.54%
Maintainers
1
Weekly downloads
 
Created
Source

brython

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:

    <html>

        <head>
            <script type="text/javascript" src="/path/to/brython.js"></script>
        </head>

        <body onload="brython()">

            <script type="text/python">
            from browser import document, alert

            def echo(event):
                alert(document["zone"].value)

            document['mybutton'].bind('click', echo)
            </script>

            <input id="zone"><button id="mybutton">click !</button>

        </body>

    </html>

To use Brython, all there is to do is:

  1. Load the script brython.js. If you want to use modules from the standard library, also load brython_stdlib.js
  2. Run the function brython() on page load, like <body onload=brython()>.
  3. Write Python code inside tags <script type="text/python"> or linking it.

Main features

Brython supports most of the syntax of Python 3, including comprehensions, generators, metaclasses, imports, etc. and many modules of the CPython distribution.

It includes libraries to interact with DOM elements and events, and with existing Javascript libraries such as jQuery, 3D, Highcharts, Raphael etc. It supports lastest specs of HTML5/CSS3, and can use CSS Frameworks like Bootstrap3, LESS, SASS etc.

Test Brython online

If you want to test Brython online you can visit the following:

There is a gallery of examples where you can see simple and advanced examples using vanilla Brython or interacting with other javascript libraries.

Documentation

Documentation is available on the official site. You can read the docs in English, French and Spanish.

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.

Keywords

FAQs

Package last updated on 28 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc