3 ms·
> Seems that relative import is implemented as relative to where the python.exe executed instead of the place where the file is. That's not true, why do you th
by PurpleRamen 3y ago
> Seems that relative import is implemented as relative to where the python.exe executed instead of the place where the file is.
That's not true, why do you think that? Relative Imports are anoying BS, but by default they do work based on the package-hierachy of the executed file, at least with normal Python. It could be there is something in your setup or handling of imports which changes this behaviour, as changing the import-mechnism is possible in python.
> So the nature is depending on where you run the doctest or where you put your jupyter notebook, all imports inside the project will break!
Maybe in those cases, the executed file is not what you think it is? So your top-level package is not located where your test is. Do you execute the test-file directly (python3 test.py), or do you use some starter-script (py.test test.py)?
- akasakahakada 3y ago> Relative Imports are anoying BS Anoying because someone 20years ago wrote this bug and no one is able to see and fix it. People derived many workarounds to deal with this flaw , but the design flaw remain unchanged.