Comment by Jtsummers
3 days ago
> You can't do something like `import ../../foo/bar`.
https://docs.python.org/3/reference/import.html#relativeimpo...
You'd use:
import ...foo.bar
3 days ago
> You can't do something like `import ../../foo/bar`.
https://docs.python.org/3/reference/import.html#relativeimpo...
You'd use:
import ...foo.bar
Common misconception. That doesn't import by relative file path; it imports by relative package path. It's actually quite different. Scripts you run directly aren't in a package so you can't use it at all. You can go above the package root. Namespace packages mean it can jump to other directories.
Everyone wants that to just mean "import relative to this file" but it doesn't.