PyScript: Run Python In The Browser and Say Goodbye To JavaScript

PyScript was announced at PyCon 2022 by the director of Anaconda Inc., Perter Wang. Here's are some quick bytes about it:

What is PyScript?

Using PyScript, you will be able to run python code within HTML. Its goal is to combine several technologies that help build sophisticated and elegant UI applications in the browser. Currently, PyScript supports running popular packages such as numpy, pandas, scikit-learn, etc.

What problem is PyScript solving?

Before PyScript, Python developers were required to learn JavaScript for web applications. Now Python developers can feel native to web apps and develop their apps with python itself.

How to use Pyscript?

To run Python code within PyScript, you need to add a couple of lines of code in the header section of your HTML file. Once done, you can use PyScript in 2 ways:

  1. You can place the python code inside the HTML tag. Also, you can pass the source file within the tags.

  2. To enable the REPL or interactive behavior, you place python code within the tag

What will be the benefits?

  • Data Scientists can now use the d3js wrapper and Altair to perform advanced data visualization straight in the browser.

  • No need to learn web frameworks like JavaScript for your web apps. You will now be able to write widgets using PyScript instead of JavaScript.

  • Facilitates bi-directional communication between JavaScript and Python objects and namespaces

  • You can also format your python application using Markdown.

PyScript will enable developers to focus on seamless development and solving real problems rather than worry about servers, web stacks, deployments, etc. PyScript is in the alpha stage right now and will only get better with time and contributions from the python community. More information can be found here: https:\pyscript.net

Did you find this article valuable?

Support Saurabh's Blogs by becoming a sponsor. Any amount is appreciated!