My apologies if this post is a bit inappropriate, but I'm desperate for comments on a programming problem.
I have been frustrated for years about what I believe is a Python design flaw, and many others agree. It's about how import statements work, particularly code like:
from ..mypackage import mymodule
from ..mypackage.mymodule import mymethod
from .. import mypackage
and similar statements.
Only the most simple, contrived, canonical cases actually work. Anything else results in the error message:
ImportError: attempted relative import with no known parent package
I use sys.path.append() as a workaround, but that should not be necessary, and it is not portable.
It seems the issue revolves around where Python thinks the importing module is in the file system at the time it attempts to execute the import statements. My opinion is that Python should be able to figure out if it is in a package and exactly where in the file hierachy that is. The import statements should work as expected if the importing module is called from another module, or if it is run from an interpreter, or PyCharm, IDLE, Spyder, or by some other way.
There is a SO post, Relative imports for the billionth time, which addresses this problem. The main article plus 15 answers and 36 comments indicate that this issue has been around for a long time. Many very smart people have offered exotic explanations and proposed cumbersome solutions to an issue that should not exist, and yet the powers that control the development of Python have not moved on the matter. It should not be necessary to be knee deep in Python internals in order to write a simple application. That's whole idea of a high level language; this is not C++.
Someone reading this must have influence with Python developers. Please use it.
Any comments, please.