python package icon
python/python

wasi

Public
wasmer run python/python

Python

Python is now compiled to WebAssembly and WASI, so it can run in your server or in your browser.

$ python
Python 3.12.0 (heads/wasix-compatibility-dirty:186ebc7b8b, Oct  3 2023, 10:47:09) [Clang 15.0.6 ] on wasix
Type "help", "copyright", "credits" or "license" for more information.
>>>

Examples

Here are a few examples of Python programs that you can try:

Hello World

This is a program that reads the input and prints it:

name = input("What's your name? ")
print(f"Hello, {name}!")

Mandlebrot

A mandlebrot program:

w = 40.0
h = 25.0

def mandel():
    y = 0.0
    while y < h:
        x = 0.0
        while x < w:
            Zr, Zi, Tr, Ti = 0.0, 0.0, 0.0, 0.0
            Cr = 2 * x / w - 1.5
            Ci = 2 * y / h - 1.0

            i = 0
            while i < w and Tr + Ti <= 4:
                Zi = 2 * Zr * Zi + Ci
                Zr = Tr - Ti + Cr
                Tr = Zr * Zr
                Ti = Zi * Zi
                i += 1

            if Tr + Ti <= 4:
                print('*', end='')
            else:
                print('.', end='')

            x += 1
            yield

        print()
        y += 1
        yield

# run the mandelbrot

try: from browser import request_animation_frame
except: request_animation_frame = None

gen = mandel()
def gen_cb(_time=None):
    for _ in range(4): gen.__next__()
    request_animation_frame(gen_cb)
if request_animation_frame: gen_cb()
else: any(gen)

Python is an interpreted, high-level, general-purpose programming language


Github
More packages
wasmer/python-flask-worker py worker
Browser site for python.
python web shell
christoph avatar
christoph
christoph avatar
christoph
python web shell
Pxlmastr
Pxlmastr
Pxlmastr
Pxlmastr
python web shell
zegevlier avatar
zegevlier
zegevlier avatar
zegevlier
python web shell
Igor
Igor
Igor
Igor
Description for package python-on-the-web
habuayush avatar
habuayush
habuayush avatar
habuayush
python web shell
Rudra
Rudra
Rudra
Rudra
kmpartner/python-docs py worker
kmpartner
kmpartner
kmpartner
kmpartner
wasmer/python-http-server py worker

Making software universally accessible