PyScript Let Users to Run Python Programs in the Browser

The Founder of Anaconda, Peter Wang revealed a new project “PyScript” at PyCon US 2022. Specifically, this project facilitates Python to take a serious step towards making programming and data science more accessible to everyone.

“PyScript is a framework that allows users to create rich Python applications in the browser using a mix of Python with standard HTML. It aims to give users a first-class programming language that has consistent styling rules, is more expressive, and is easier to learn”, reads the blog post published by Anaconda.

The Core Components of PyScript:

PyScript is just HTML, more powerful that includes a rich and accessible ecosystem of Python libraries. The key components include:

  • Facilitate drop-in content, external file hosting (via Pyodide project)
  • Allows using Python and its vast ecosystem of libraries (including numpy, pandas, scikit-learn) from within the browser.
  • Bi-directional communication between Python and Javascript objects and namespaces.
  • Environment management helps users to decide which packages and files to include for the page code to run.
  • Allows creating curated UI components, such as buttons, containers, and more.
  • Flexible framework to create and share newly pluggable and extensible components directly in Python.

Therefore, PyScript offers a clean and simple API, supports standard HTML, extends HTML to read custom components that are opinionated and reliable, and also provides a pluggable and extensible components system.

Working with PyScript:

To try PyScript, import the appropriate pyscript files to your html page with:

<link rel=”stylesheet” href=”https://pyscript.net/alpha/pyscript.css” />

google

<script defer src=”https://pyscript.net/alpha/pyscript.js”></script>

  • <py-script>: Used to define python code that is executable within the web page. The element itself is not rendered to the page and only used to add logic.
  • <py-repl>: Creates a REPL component that is rendered to the page as a code editor and allows users to write code that can be executed.

Therefore, PyScript supports writing and running Python code in a browser. The objective for the future is that it will also provide support for other languages.

You can follow us on LinkedinTwitterFacebook for daily Cybersecurity and hacking news updates.

googlenews
Guru Baran
Gurubaran is a co-founder of Cyber Security News and GBHackers On Security. He has 10+ years of experience as a Security Consultant, Editor, and Analyst in cybersecurity, technology, and communications.