Skip to content

Documentation ​

What is Basthon? ​

Basthon stands for "Bac À Sable pour pyTHON" — a sandbox for Python. It sounds like the French word "baston", a brawl: a nod to the fight that learning to program, writing code or debugging it can sometimes be.

Basthon is used to get started with the Python 3 programming language (and also SQL, OCaml, JavaScript, XCAS, C and R!), with nothing to install. All you need is an up-to-date browser (Firefox, Chrome, Chromium or Edge) and an Internet connection. The Python version is 3.12, provided by Pyodide (Python compiled for the browser).

Astuce

Basthon can be used to get started with other languages than Python! See the Other languages page.

Two interfaces let you use Basthon:

Basthon-ConsoleBasthon-Notebook

Both interfaces can be reached from the home page of https://basthon.fr. There is also an offline version, Basthon-Desktop, installed on the computer, and a basthon command to use it in a terminal.

Info

For more information on the Basthon project, see the project's page. You will read there, among other things, that Basthon is very respectful of your privacy.

Astuce

A problem? The most frequent ones are on the Troubleshooting page.

Astuce

The best way to discover Basthon may be to browse the gallery of examples and to have a look at the section Examples of use.

Info

Both interfaces of Basthon are "static" sites: your browser does the work, not the server, which only serves files. As a consequence, Basthon costs very little to the server, which can therefore handle a large number of connections, especially when your browser caches the resources.

If you still have a doubt, you can always install Basthon on your own web server: see Hosting Basthon on your own web server.

Examples of use of Basthon ​

Basthon has a gallery of examples, from which you can load scripts or notebooks that show a few possible uses of Basthon.

The gallery of examples

You can for instance plot curves with Matplotlib;

Curves with Matplotlib3D surface with Matplotlib

or draw with Turtle;

Spiral with TurtleWriting with Turtle

You can also display graphs (with Graphviz), maps and routes (with Folium and Pyroutelib3) or even process images (with PIL).

Graph with GraphvizMap with FoliumImage processing with PIL

The p5.js library is available too, to animate objects, display 3D models, interact with the user…

Balls animated with p53D torus with p5

QR codes are easy to make with the qrcode module, and PythonTutor shows the run of a program as a diagram.

QR codePythonTutor

By the way, if you like PythonTutor, you will probably enjoy the lolviz and rcviz modules, which show data structures and recursive function calls respectively:

Data structures with lolvizRecursive calls with rcviz

There is also binarytree to handle and display binary trees, and ipythonblocks to learn Python visually:

Binary tree with binarytreeGrid with ipythonblocks

Info

The documentation specific to some modules is on the Modules adapted to Basthon page.

The Python modules available in Basthon ​

In the console as in the notebook, the help('modules') command lists the modules that Python can import. Its output is given on the Available Python modules page. The documentation specific to some modules is on the Modules adapted to Basthon page.

Advanced use ​

To go further, see the pages on isolated kernels, the self-assessment of Python notebooks and the API of the basthon Python module.

Licence and credits ​

This documentation is released under the Creative Commons "Attribution – NonCommercial – ShareAlike 4.0 International" licence.

Info

More information on the third-party resources used in Basthon here.