Videos
Hello, im not new to python, but ive always liked to play around with it in school using different python fiddle sites etc, but as school gets more boring (dw i got good grades) i wanna play around a lot more between classes etc, but ive noticed none of the fiddles / compilers ive found lets you import custom libraries, ive really wanted to play around with Textual, but they really just offer libraries like pandas.
There was one site that was perfect, replit. But as you may know, replit is now an AI platform with a free plan of only 2 developement hours, even if you dont use the AI. So i came here to ask for an alternative, is there a website where, i can code (prefferably through multiple files), install ANY pip library, run code, use the terminal etc.
Edit: FYI: Most google services are blocked by the IT (chromewebstore, colab, maps etc, so no colab)
You can compile C code using only the standard library, and it will work on every platform and with every Python version (assuming you actually have a C compiler available). Check out the distutils.ccompiler module which Python uses to compile C extension modules. A simple example:
// main.c
#include <stdio.h>
int main() {
printf("Hello world!\n");
return(0);
}
Compilation script:
# build.py
from distutils.ccompiler import new_compiler
if __name__ == '__main__':
compiler = new_compiler()
compiler.compile(['main.c'])
compiler.link_executable(['main.o'], 'main')
Everything else (include paths, library paths, custom flags or link args or macros) can be passed via various configuration options. Check out the above link to the module documentation for more info.
Sure, why not? Of course, you'd need GCC installed (or llvm) so you have something to compile with. You can just use os.system, or any of the other ways for calling an external program.
Of course, you're probably better off looking at something like SCons, which already exists to solve this problem.
Plus, to answer the question actually asked, there's nothing that would prevent you from writing a compiler/assembler/linker in python, they're just programs like anything else. Performance probably wouldn't be very good though.