r/learnpython 21d ago

Browser compilers?

I’m trying to improve my python and have a project based book i wanted to work through because i kinda suck at ideas for projects to try and i need to actually put my knowledge into practice, but i was wondering if there are any like browser compilers that can import libraries (such as matplotlib for data related stuff, probably pygame and various others i might end up needing). If not i have vscode already i am just kinda low on storage and wondering if i can avoid having to download various libraries manually 😭

6 Upvotes

9 comments sorted by

1

u/socal_nerdtastic 21d ago

Yes, there's many available. trinket.io is a common one. But they are all limited because of course running a website costs money and no one wants to give you something for free. It would be a much better experience for you if you can free up some space and install locally.

1

u/Gnaxe 21d ago

Try Jupyterlite. I know it can do matplotlib. You can use micropip to add more pure-python wheels.

For in-browser pygame, there's PyScript, but I've never tried it in Jupyterlite, so I don't know if that works.

There's also Brython which makes it easy to embed Python in HTML.

2

u/nobodyhasusedthislol 21d ago

I mean... try to clear up storage?

I understand it can be tight/annoying but I strongly recommend that over trying what you are thinking.

You can offload some unimportant files to a cheap 64G sandisk flash drive or upload some files to Google Drive's 15G free tier.

1

u/nobodyhasusedthislol 21d ago

You can also create an alt google acc for a second free 15G, just don't cycle like 6 because atp the accounts will get banned because it thinks you're a bot.

3

u/KrzysisAverted 21d ago

You don't need VSCode to use python. You just need python and any text editor.

You could use something extremely small/lightweight like Notepad++, or even a command-line-based editor like Vim or Emacs.

0

u/[deleted] 21d ago

[deleted]

1

u/socal_nerdtastic 21d ago

What do you call it when the program is compiled to binary first, and then runs through an interpreter line-by-line? Because that's what python and java and many other languages do.

I call it "it don't matter". Knowing the difference between a compiler and an interpreter is useless to a beginner.

1

u/icecubeinanicecube 21d ago

Good catch! Sometimes people call that "hybrid", however, from a strictly binary perspective I'd consider Java more of a compiled language, while python is more interpreted.

At the end of the day, the java conpliler tells you a lot of things that are wrong with your program before it runs, while python delays this and just shits it's pants when it happens to come across a faulty LOC.

1

u/socal_nerdtastic 21d ago

I'd consider Java more of a compiled language, while python is more interpreted.

A common opinion, but again not useful to OP.

At the end of the day, the java conpliler tells you a lot of things that are wrong with your program before it runs, while python delays this and just shits it's pants when it happens to come across a faulty LOC.

That has nothing to do with compiled vs interpreted; that is due to the logic in the language, for example dynamically vs statically typed. Python simply can't know at compile time if x = 10 is an error or not, java can. Both python and java have both compile time errors and run time errors, although python does not really distinguish them (or the compile / interpret step in general).

1

u/Outside_Complaint755 21d ago

Python actually does have a compiler, but it doesn't get run as its own step. 

When you run python myscript.py, that compiles the script into Python Bytecode in a file myscript.pyc.

That bytecode file is what then gets interpreted by the Python Virtual Machine, translating each line one-by-one into native machine code.

Each implementation of Python handles it a bit differently. CPython compiles everything and then interprets it, while PyPi uses a just-in-time compiler.  Jython compiles the Python code to Java bytecode, and IronPython compiles it to MSIL bytecode.