Can I place:
from __future__ import absolute_import
inside __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.
No,
__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: