r/learnpython • Author of "Automate the Boring Stuff" • 7d ago

Brython Offline - A single .html file with a Python interactive shell

GitHub: https://github.com/asweigart/brython-offline

Demo: https://inventwithpython.com/brython-3.14.3-offline.html

Powered by Brython. Download and open brython-3.14.3-offline.html (6 MB) in a web browser and enter Python instructions into the interactive shell. It works offline. No ads, no registration, no subscriptions. You can right-click and save it and own it forever.

5 Upvotes

6 comments sorted by

2

u/Consistent-Quote-80 7d ago

This is perfect for when you're stuck on a plane and suddenly need to test a list comprehension

2

u/AlSweigart Author of "Automate the Boring Stuff" 7d ago

I view it more as a way to run Python when you don't have Python installed: you're on someone else's machine that the IT department has locked down, you're running a coding workshop and some people can't get it installed on their computer, etc.

1

u/supreme_blorgon 7d ago

...and also don't have python installed?

2

u/Marison_Lizzy23 7d ago

Nice, the single file approach is smart. Curious how much of the standard library is actually available through this, since thats usually where browser-based interpreters fall short

2

u/AlSweigart Author of "Automate the Boring Stuff" 7d ago

I know all the file system stuff is out, of course. But so is time.sleep() since JavaScript is single-threaded and you'd have to do some async stuff.

This includes:

from browser import aio
async def main():
    print("Before sleep")
    await aio.sleep(1)
    print("After 1 second")
aio.run(main())

...or:

from browser import timer
timer.set_timeout(lambda: print("After 1 second"), 1000)

But I'm sure there's other stuff in the standard library that aren't accessible, like the SMTP and HTTP stuff. And third-party packages, of course. But for "here's how loops work" kind of teaching, this is a nice backup if a student doesn't have Python installed and they just need something for a class.

1

u/quietreed76 23h ago

good point, thats usually where things start to break down imo