PyScript was announced on April 30th 2022 at PyCon US by Peter Wang, CEO of Anaconda Inc., and in an accompanying blog post. The announcement sparked a lot of interest and excitement in the Python community and generated a lot of hype.
In this post, I will summarize my experience with PyScript so far and give some examples to help you get started:
PyScript brings Python and its ecosystem to the browser
At its core, PyScript allows you to add Python code to your HTML by introducing a new
<html> ... <py-script> print('Hello World!') </py-script> </html>
What is HUGE is that you can simply use your favorite Python packages by defining a
<html> ... <py-env> - numpy - pandas - seaborn </py-env> ... </html>
Again, this is Python running in a browser - including numpy, pandas, and seaborn/matplotlib - 🤯🤯
You can even load your own
.py files in PyScript:
<html> ... <py-env> - paths: - https://raw.githubusercontent.com/JungeAlexander/pyscript-demo/main/helpers.py </py-env> <body> <py-script> from helpers import say_hello print(say_hello("Stranger")) </py-script> ... </html>
So far, PyScript feels like a tech demo
PyScript builds on Pyodide, a port of CPython to WebAssembly/WASM which in turn is supported by modern browsers.
For now, PyScript feels like a (really cool) tech demo - but still like a demo: loading PyScript HTML websites is slow, PyScript itself is experimental and there is a growing list of issues and fixes.
PyScript for sure is real and cool but there is a lot of hype, too. Only time will tell if PyScript will live up to its goals and democratize programming further by bringing Python and its vast package ecosystem to every browser out there. There is still a lot to be done but PyScript for sure is fun to explore and I look forward to seeing where things are going.