Comment by IshKebab
2 days ago
Python is actually kind of awkward for this use case since you can't import from other files easily unless you are in a proper Python package, which isn't usually the case for everyday scripting.
2 days ago
Python is actually kind of awkward for this use case since you can't import from other files easily unless you are in a proper Python package, which isn't usually the case for everyday scripting.
Lol what.
Python lets you dynamically import from anywhere. The syntax is a bit funky, but thats what llms are for.
No it doesn't. You can't do something like `import ../../foo/bar`. You can mess around with PYTHONPATH and importlib to work around that but that's a horrible hack that also breaks all tooling. Not a good idea.
With Deno you can just import by relative file path and it just works like you'd expect and the tools support it. I wish more languages worked like that.
> You can't do something like `import ../../foo/bar`.
https://docs.python.org/3/reference/import.html#relativeimpo...
You'd use:
1 reply →
>You can mess around with PYTHONPATH and importlib to work around that but that's a horrible hack that also breaks all tooling
....no.
import keyword uses importlib under the hood. It just does a lot of things for you like setting up namespace. But importlib has all the functionality to add the code in any python file cleanly.
My custom agent that I use basically has the functionality to wrap every piece of code it writes as a tool and stores it into python files. During tool calls, it pretty much dynamically imports that code as part of a module within the project. Works perfectly fine.
1 reply →