Experiments with Running python in the browser

python
Published

March 11, 2024

Original

I started on this on 2023-5-22, and paused it since nothing interesting came out of it.

My goal is an in browser python editor I can embed into a blog. I want to create a sort of interactive python tutorial.

Code is ran client side, so don’t try to crash any server or anything like that.

Recent updates

There was a new quarto extension, enabling you to embed pyodide python code blocks in documents: https://github.com/coatless-quarto/pyodide

This works, but the blocks don’t show up properly. In addition to that, the input function doesn’t work.

But still, if I want to do a simple python tutorial, this would be pretty doable. In addition to that, I could also do block posts about other interesting things in python.

Older work below

This might not render, since many of it is raw html elements.

Lots of rot happened since I first played with this, and I disabled all of this stuff since it doesn’t load, and instead prevents the newer work from loading.

Awww, the input function doesn’t seem to work.

Shift + enter/return to evaluate code of the below.

This kinda works, but also has issues. Input fucntion still doesn’t work.

Shift + enter/return to evaluate below. Or double click.

import numpy as np np.random.rand(5)

This is cool, but the code isn’t editable. It just resets itself for some reason.

Maybe this will work?

Open the project Untitled Project in LiveCodes


yeet = input("test")

print(yeet)