I have read this post, and it is very helpful. How to import the class within the same directory or sub directory?
However, in Python3, it requires a dot if an import is in the same directory. This makes the whole point (of importing both from same and sub directory) meaningless.
Only one of these two works, based on where the script is called:
from some_class import * # calling within the same directory
or
from .some_class import * # calling from somewhere else, as part of a module
I want the script to be called in the folder and as a part of a module, and have a dirty solution as follows:
try:
from some_class import *
except:
from .some_class import *
Are there any better solution, the best one statement ones?