A chainsaw can do a brief job of cleaning the back forty. It can also make a good horror movie. So while some people will say that we don’t need any other tools to allow more malicious scripting in the browser, we also know that, like any tool, you can use or abuse it. That tool? PyScript, of course, Python in the browser.
However, the real goal is to make web-based programming accessible to newcomers, just like programming systems like Scratch or JSFiddle. 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.
So how difficult is it to create PyScript code? Not much:
<!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>
The funny thing is that no server setup is required for this. Save that text to a file, open it in a browser and run it. Well, of course, set up a server for you. Most likely, the work is being done on pyscript.net server which takes a lot of set up! There is also some load time for this simple thing, as you might expect, especially in the first load. However, you can host your own server.
Some people will like it, and others will hate it. Either way, here it is, and if you have to script in a browser, you can do worse than Python. We’re still holding on to Fortran, though we should upgrade to Forth.