PyScript 🐍📜


You want to share this Python app with Grandma.

 print("Hello, world!")



PyScript is...

...A platform for Python

in the browser.

PyBunny 🐰

Polyglot 🏴‍☠️ 🦜☠️


  • Pyodide
  • MicroPython
  • Lua
  • Ruby
  • ???

import js  # globalThis

from pyscript import window

from pyscript import document 
<button id="click-me">Click me! 🐭</button>
from js import document

def handler(e):
    It's just Python! Access the DOM!
    output = document.createElement("span")
    output.innerHTML = "🖱️"

button = document.querySelector("button#click-me")
button.addEventListener("click", handler)

Clicky Mouse-o-Matic 🐁

Lights 💡 Cameras 🎥 Action 😄

from pyscript import document
import time

counter = document.getElementById("counter")
i = 1

while True:
    counter.innerHTML = str(i)
    i += 1
<script type="mpy" src="./" worker></script>

Final thoughts

  • PyScript is a platform.
  • It runs everywhere a browser runs.
  • Anything a browser can do, so can PyScript.
  • Write code and frameworks on PyScript.
  • It's open source... come play!
  • For the 99% (not just coders).

What's next?


TL;DR: - try 🐍 - docs 📖 - chat 💬

Image credits

Photo by Dulcey Lima on Unsplash

Photo by Becca Tapert on Unsplash

Photo by Christian Wiediger on Unsplash

Photo by Valery Sysoev on Unsplash

Photo by Mathew Schwartz on Unsplash

Photo by Lia Trevarthen on Unsplash

Photo by Eric Wang on Unsplash