In Python3, the unfortunate decision was made to remove the functionality of relative imports. I'm currently in the process of modernizing a large amount of Python2 code that makes some heavy use of this feature.
So, right now, I have code that is to the effect of:
import other_function
import another_class_file
...
foo = other_function.calculate_foo() + other_function.constant
bar = another_class_file.Bar(foo)
And as far as I am aware, the "correct" way to do this in Python3 is to:
from other_function import foo as calculate_foo
from other_function import constant
from another_class_file import Bar
....
foo = calculate_foo() + constant
bar = Bar(foo)
But this way feels extremely filthy: instead of always knowing exactly where a function or class comes from, it's all just getting thrown at the top level, and the only way of knowing where something comes from is by looking at the list of import statements at the top. Overall, the code becomes much more ambiguous as a result; explicit is better than implicit.
Is there any way I could achieve the same notation, something akin to from other_function import foo as other_function.calculate_foo? I do not want to have to manually name these things Hungarian-style.