Can I place:
from __future__ import absolute_import
__init__.py on the top level dir on my package and garantee that the absolute_import will be applied to all code that runs inside that package or sub-packages?
Or should I put that directive in each model that does an absolute import?
I maintain a Python package and I’m trying to keep my code as easy as possible to migrate to Python3 when the time comes. I can’t do it right away because my dependencies are not on Python3 yet.
__future__ imports are only valid for a single file. You will have to put this line at the top of every Python source file.
From the documentation:
A future statement is a directive to the compiler that a particular module should be compiled using syntax or semantics that will be available in a specified future release of Python.