I found this answer very useful to understand relative imports in Python. However I have found difficulty in getting VS Code's "Current File" to play nicely with this, since it launches the file directly using ${file}.
To summarise said answer, suppose we have a structure like this:
mymod/
__init__.py
apple.py
orange.py
If orange.py imports something from apple.py:
from .apple import apple_function
then the correct way to run orange.py as a script without an ImportError is with the following command from the directory containing mymod:
python -m mymod.orange
Currently, I manually enter a command similar to the above into the terminal, which works, but I'd prefer to use a keyboard shortcut that works regardless of filename and saves me some typing.
Is there anything I can add to the launch.json to have a configuration that launches python for each particular file as above automatically?