I want to import a function from another file in the same directory.
Sometimes it works for me with from .mymodule import myfunction but sometimes I get
from .mymodule import myfunction
I think the best solution is to create a package for your module: Here is more info on how to do it.
Once you have a package you don't need to worry about relative import, you can just do absolute imports.