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.
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.
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=" /> <script defer src=" </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.