E Amazings
  • Home
  • Automotive
  • Business
  • CBD
  • Crypto
  • Education
  • Entertainment
  • Fashion
  • Finance
  • Health
  • Home Improvement
  • Law \ Legal
  • News
  • Shopping
  • Sports
  • Technology
  • Travel

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot

Closing Bell: Nifty near 16,000, Sensex gains over 600 points; Auto, FMCG, Realty shine

July 6, 2022

Macroeconomic Factors to Blame for Crypto Crash With More Pain Likely to Come: Coinbase Report

July 6, 2022

Samsung Galaxy M13 series India launch set for July 14

July 6, 2022
Facebook Twitter Instagram
E Amazings
  • Home
  • Automotive
  • Business
  • CBD
  • Crypto
  • Education
  • Entertainment
  • Fashion
  • Finance
  • Health
  • Home Improvement
  • Law \ Legal
  • News
  • Shopping
  • Sports
  • Technology
  • Travel
Facebook Twitter Instagram
E Amazings
You are at:Home»Technology»PyScript: Python In The Web Browser
Technology

PyScript: Python In The Web Browser

Paul EasterBy Paul EasterJune 9, 2022No Comments3 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Share
Facebook Twitter Pinterest WhatsApp Email


A chainsaw can make short work of clearing out the back forty. It can also make a good horror movie. So while some people will say we don’t need another tool to allow more malicious scripting in the browser, we also know that, like any tool, you can use it or abuse it. That tool? PyScript, which is, of course, Python in the browser.

The tool is in the early experimental phase, so the project doesn’t suggest using it in a production environment yet. However, if it works well, the promise is not just that you can write browser-based applications in Python — you’ll have a handy way to reuse existing Python code and even be able to run the same code on the browser that currently runs on the server. This has a lot of implications for improved client/server applications, or cases where you want to be able to run against a local backend when disconnected and a remote backend when you do have a connection. Of course, you can interoperate with JavaScript, too.

However, the real goal is to make web-based programming accessible to beginners in the same way as programming systems like Scratch or JSFiddle do. As such, the actual project is less of a piece of software and more of an integration between existing pieces. According to the post:

PyScript is a single-page application (SPA) written in TypeScript using the Svelte framework, styled with Tailwind CSS, and bundled with rollup.js.

PyScript wouldn’t be possible without building on top of a recent version of Pyodide—a CPython interpreter compiled with emscripten to WebAssembly, enabling Python to run in the browser. PyScript provides a thin abstraction layer over Pyodide by encapsulating the required boilerplate code, which you’d otherwise have to type yourself using JavaScript.

So how hard is it to create PyScript code? Not very:



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, World!</title>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-script>print("Hello, World!")</py-script>
</body>
</html>
</pre>

What’s interesting is that this requires no server set-up whatsoever. Save that text to a file, open it in a browser and it runs. Well, of course, no server set-up for you. Presumably, the work is being done on the pyscript.net server which takes a lot of set-up! There’s also a bit of load time for something this simple, as you might expect, especially on the first load. You can, however, host your own server.

Some people will love this, and others will hate it. Either way, it is here, and if you have to script in the browser, you could do worse than Python. We are still holding on to Fortran, though maybe we should upgrade to Forth.

Paul Easter

Related Posts

3D Print Your Own Multi-Color Filament

By Paul EasterJuly 6, 2022

Scratch-Built Electric Buggy Tears Up The Dunes

By Paul EasterJuly 6, 2022

Classic Amp Revived With A Pi

By Paul EasterJuly 6, 2022

Never Miss An Email With This 1970s Style Desktop Notifier

By Paul EasterJuly 5, 2022
Add A Comment

Comments are closed.

Our Picks

Closing Bell: Nifty near 16,000, Sensex gains over 600 points; Auto, FMCG, Realty shine

By Paul EasterJuly 6, 2022

Macroeconomic Factors to Blame for Crypto Crash With More Pain Likely to Come: Coinbase Report

By Paul EasterJuly 6, 2022

Samsung Galaxy M13 series India launch set for July 14

By Paul EasterJuly 6, 2022
Recent Posts
  • Closing Bell: Nifty near 16,000, Sensex gains over 600 points; Auto, FMCG, Realty shine July 6, 2022
  • Macroeconomic Factors to Blame for Crypto Crash With More Pain Likely to Come: Coinbase Report July 6, 2022
  • Samsung Galaxy M13 series India launch set for July 14 July 6, 2022
  • CryptoCom CEO Denies Imposing Withdrawal Restrictions July 6, 2022
  • Housing sales in Jan-Jun at 9-year high in top 8 cities; sales see 60 per cent annual growth: Knight Frank July 6, 2022
  • SOL Stuck in a Range, Breakout Inbound? July 6, 2022
  • Bajaj Auto looks to sell Chetak from 75 locations in current fiscal July 6, 2022
Archives
  • July 2022
  • June 2022
Facebook Twitter Instagram Pinterest TikTok
  • Home
© 2022 E Amazings - All Rights Reserved.

Type above and press Enter to search. Press Esc to cancel.