sometimes I forget that Python is a scripting language with dynamic imports. then I remember, and remember that you can use subprocess from WITHIN Python to install a package and then LOAD that package in the same interpreter absolutely cursed

Oct 29, 2025 · 10:42 PM UTC

Replying to @tritlo
you can do it in every language, from c to java
1
31
you have to jump through a bit more hoops in compiled languages, and in eg Haskell you can’t just drop things into the current module, you need to typecheck and link etc
3
1
27
Replying to @tritlo
that’s insane, I’d love to see a practical use case for this. perhaps conditional imports on extremely storage constrained environments?
11
12
we don't need dependency management at all, you can just install your own as you go lmao
2
1
66
Replying to @tritlo
Carpenters don't smite their hammer just because someone hit their thumb.
1
1
7
some of us build safer, more effective hammers for a living lmao
3
4
Replying to @tritlo
hot load/reload can be a bliss imo, but only if you have enough checks before linking and loading new object code to your repl/interpreter, otherwise it's cursed (like in python lol)
2
6
for sure and you can do this in ghci btw, just not in the compiled ghc (i'm going to say "due to type-erasure", but that might be wrong)
1
This is common practice in Jupyter notebooks! Not ideal dep management but very practical
2
4
Replying to @tritlo
it's everything cool they promised you could do with lisp machines, and even more beyond that
Replying to @tritlo
You could do the same in C++, is C++ cursed too? I mean yeah it is, but that's not the reason
Replying to @tritlo
You can do the same crime in C: int err = system("sudo apt-get install libfoo-dev"); void *foo = dlopen("libfoo.so",RTLD_NOW); (Also cursed!)
2
31
Replying to @tritlo
Subprocess? That's a pleb approach! Here's what you can REALLY do:
1
27
Replying to @tritlo
I once saw consultants webscrape the text of their Python files stored on github, then load this entire file into the runtime context by using 'exec()' on the resulting string Python is amazing
10
Replying to @tritlo
You can also just `import pip` and not bother with the subprocess
10
Replying to @tritlo
average python interpreter moment
1
7
Replying to @tritlo
Write to file and import is new eval lmao
5
Replying to @tritlo
please just use uv's script dependencies docs.astral.sh/uv/guides/scr…
4
Replying to @tritlo
I know you’re joking but I recently packaged a Laravel app that did exactly this: on startup the package downloads the most recent version of a different library to use.
4
Replying to @tritlo
lisp enjoyers will never recover from this
4
Replying to @tritlo
People coming from static languages like to throw around "scripting language" as if it means something. A dynamic language once saved a satellite - researchers were able to send it a few LISP expressions to evaluate that fixed serious bugs.
1
3
Replying to @tritlo
Cursed? You misspelled "based."
2
Replying to @tritlo
You ever use dynamically generate python to regenerate the dynamically generated python and then reimport itself?
2
Replying to @tritlo
Lol that's hilarious makes sense they're just folders
1
Replying to @tritlo
There's actually a package for doing this automatically. I've used it when a test needs a package that's mutually exclusive from another package needed for a different test github.com/pomponchik/instld
1
Replying to @tritlo
you know, they should make python in such a way that when the interpreter sees `import requests`, it automatically install requests if not found 🤣
1
Replying to @tritlo
I was once working with a Node.js chatbot program for a chat app. Because I wanted to make it automatically reload every time I edit/write a new feature, I heavily used require() function inside a fs.watchAll() or use an eval() that only I can access to run exec() to install smth
1
Replying to @tritlo
Machine learning people love doing this shit. Then I have to debug why their ml app take 15 minutes to start in Kubernetes.
1
Replying to @tritlo
You can do this in C too. using system()/libcurl and and dlopen(). And then use @Tsoding's patched tcc to do `include over http`.
1
Replying to @tritlo
uhh... and? I think most people using Python professionally struggle to understand why you are surprised about this.
1