PyScript unveiled at PyCon US 2022

PyScript unveiled at PyCon US 2022

Py, oh my! Web development with Python is easier than ever

This post is from Grokking Python, a free newsletter available on Substack from Educative, the world’s best learning platform for software developers. It’s where we’ll share our team’s best Python-related info and resources—stuff we think could really enhance your understanding.

Hey Grokking Python readers!

Peter Wang, CEO of Anaconda, gave an exciting keynote speech at PyCon US 2022. He revealed PyScript, an ambitious project designed to make Python as accessible and portable as HTML or JavaScript. PyScript is currently in alpha, but the future looks bright for data scientists and developers who want to build websites in Python.

#PyConUS2022 @pwang Keynote: Announcing Py-script!!!
It's Python! inside HTML!!! 🤯 pic.twitter.com/paDsibNQtt

— Mariatta 🤦 (@mariatta) April 30, 2022

What is PyScript?

PyScript is a Pythonic alternative to Scratch, JSFiddle, and other programming frameworks. It's a 100% client-side JavaScript web framework for creating interactive Python apps directly in the browser.

PyScript

  • Can interleave Python in HTML (like PHP)
  • Full access to the Python Standard Library
  • Can fully access the web page (DOM)
  • Can call and be called by JavaScript libraries
  • Is truly serverless
  • Enables 'import d3'
  • Requires ZERO installation
  • Is performant (includes utilizing GPU)

During a live coding demonstration, Wang impressed the crowd by embedding an interactive Python data visualization of NYC taxicabs in an HTML file in mere minutes.

Who is PyScript for?

If you've worked with Python, you may already know that trying to make desktop native applications with Python is frustrating, and making mobile native apps with Python is nearly impossible. This hurdle makes it difficult for Python developers to share their work with a broader audience.

Wang described the Python interpreter as having an under-the-hood engine "like a Honda Civic with mounting bolts for a warp drive." While just about anyone can learn Python syntax quickly, there is a steep learning curve to familiarizing yourself with the rich ecosystem of libraries and frameworks that make Python great.

PyScript flattens that learning curve dramatically. Now, frontend web developers, Python developers, and data scientists will all be able to share models, dashboards, data visualizations, and more without learning additional infrastructure technology. How to learn Python in 5 easy steps (for beginners) is a great article to read on Educative if you'd like to brush up on those Python skills.

How does PyScript work?

PyScript isn't a variation of the Python language. Instead, it combines multiple open source technologies to allow users to add logic and create sophisticated applications in the web browser. PyScript works by compiling CPython to WebAssembly (WASM) and Emscripten via Pyodide. WASM is a low-level assembly-like language released in 2017 that provided a way for developers to run code written in languages like C++ or Rust on the web at near-native speeds.

PyScript

Try PyScript

You can try PyScript by checking out their website or by visiting GitHub! If you'd like to build a simple web app with PyScript, there’s a quick guide to get started.

Given the interest in PyScript and some of the common questions that are coming up, I figured I'd share some of my slides which may answer some questions.

Also I highly recommend checking out our engineering blog post on it: https://t.co/I8i3BeTNJA pic.twitter.com/JBtBfIQwso

— Peter Wang (@pwang) May 2, 2022

PyScript Demos

You can take a look at some of the demos that were presented at PyCon down below.

Basic examples

MIME Rendering

JavaScript Interaction

Visualizations

PyCon US 2023

If you're a passionate Pythonista and would like to stay in the loop about future Python events, stick around. We're all lifelong learners here at Educative, and we want everyone to have access to great learning experiences.

The following PyCon US will be held in Salt Lake City, Utah, from April 19th to April 27th, 2023. We'll keep you posted when registration opens up, and we hope to see you there!

Happy learning!

Start a discussion

Will you be attending the next PyCon? Was this post helpful? Let us know in the comments below!