Python is one of the most popular and widely used programming languages. Python helps in working efficiently and effectively to build web applications. Unlike JavaScript, Python did not yet have a designated scripting language. But when Peter Wang, the CEO and co-founder of Anaconda.Inc. announced the launch of a brand new framework titled Pyscript, the internet has been caught in its storm.
Edureify, the best AI Learning App has previously provided articles on Top 10 Python Courses to Take in 2022 and Python For Loops. Edureify’s coding Bootcamp job-ready courses also provide python related courses for students to learn and grow. In this article, Edureify will update you all with the new framework called Pyscript and how it can be used for better web and application development.
Read on to know more.
What is Pyscript?
Before getting into the definition of Pyscript it should be understood that Pyscript is an experimental project. So now, what is Pyscript?
“Pyscript is a framework that enables users to create efficient Python applications in the browser using HTML’s interface and the power of Pyodide, WASM, and modern web technologies. The Pyscript framework provides users at every experience level with access to an expressive, easy-to-learn programming language with countless applications.”
To better understand, the following are some core components of Pyscript-
- Python in the browser– Without relying on a server-side configuration to host applications, it can enable drop-in content and host external files.
- Python Ecosystem- Can run many popular packages of Python and the scientific stack.
- Python with JavaScript- Can engage in bi-directional communication between Python and JavaScript objects and namespaces.
- Environment Management- Enable users to define what packages and files to include for the page code to run.
- Visual Application Development- Use UI components that are easily available, such as buttons, containers, text boxes, and more.
- Flexible Framework- Can create and share new pluggable and extensible components directly in Python.
How does Pyscript work?
Pyodide is the base of Pyscript. Pyscript is a Python distribution (port of CPython) for the browser and WebAssembly-based Node.js. the WebAssembly technology makes it possible to write websites in Python.
Pyscript is an experimental project as mentioned earlier. For now, Pyscript supports writing and running Python code in a browser. The aim behind the development of Pyscript is that it will also support other languages. As of now, only the libraries that are supported by Pyodide can be used in Pyscript.
Learn to use Pyscript
It is fairly easy to learn to use Pyscript. The following are some steps that one can learn to use Pyscript-
- Create an HTML file- One needs to first create an HTML file to display the text on the browser by using the text editor/ IDE of one’s choice.
Example-
<!DOCTYPE html> <html lang=“en”> <head> <meta charset=“UTF-8”> <meta name= “viewport” content= “width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0”> <meta http-equiv= “X-UA-Compatible” content= “ie=edge”> <title>Title: Pyscript</title> </head> <body> </body> </html>
-
- Link Pyscript- After creating the HTML file, one needs to link Pyscript to the HTML file to have access to the Pyscript interface. The link will be placed in the <head> tag.
Example- <link rel= “stylesheet” href= “https://pyscript.net/alpha/pyscript.css”/> <script defer src= “https://pyscript.net/alpha/pyscript.js”></script>
-
- Print to browser- After linking Pyscript to the HTML file, one can print their Hello, World! This can be achieved with the <py-script> tag. This tag will allow one to run multi-line Python programs and have them printed on the browser page. The tag is placed between the <body> tags.
So, to complete the above example- <!DOCTYPE html> <html lang=“en”> <head> <meta charset=“UTF-8”> <meta name= “viewport” content= “width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0”> <meta http-equiv= “X-UA-Compatible” content= “ie=edge”> <title>Title: Pyscript</title> </head> <body> <py-script> print (“Hello, World!”) </py-script> </body> </html> Your browser will have this on your screen:
Hello, World!
Other Operations with Pyscript
Some of the uses of Pyscript are-
- Attach labels to labeled items
- Run REPL in the browser
- Import Files, Modules, and Libraries
- Configure metadata
Pyscript is an alpha framework that is still evolving for better use. With the basic knowledge of HTML, Python, IDE, and browser one can easily start using this new framework for a better web application.
Edureify’s coding Bootcamp for job-ready courses aims to provide the best study materials to help interested students learn all the technical tools. Node.js, HTML Tags, C# Tutorials, Data Structures and Algorithms, and Advanced Excel Formulas are some of the many technical tools available on Edureify. For more technical tools and programming language courses, stay tuned to Edureify.
Some FAQs on Pyscript-
1. What is Pyscript?
“Pyscript is a framework that enables users to create efficient Python applications in the browser using HTML’s interface and the power of Pyodide, WASM, and modern web technologies. The Pyscript framework provides users at every experience level with access to an expressive, easy-to-learn programming language with countless applications.”
2. What is the name of the founding company that developed Pyscript?
Anaconda.Inc. is the founding company of Pyscript.
3. Is Pyscript developed completely for use?
Pyscript is an alpha framework that is still evolving for better use.
4. What are the prerequisites to use Pyscript?
Basic knowledge of HTML, Python, IDE, and browser can enable one to efficiently use Pyscript.
5. From where can I learn more about Pyscript and Python?
Edureify with its coding Bootcamp job-ready courses is here for all who are interested to learn more about Pyscript and Python, and other programming languages.