How to make absolute_import the default value in all modules

After reading on the Internet, I noticed that it was promised that Python 2.7 would use absolute imports by default. However, this does not seem to be the case, and what else do we need to use

from __future__ import absolute_import

I do not want my code to use some deprecated settings, so I want to make sure that all modules are enabled. How to do this without repeating this statement in each individual module?

+5
source share
1 answer

from __future__Import must be done first and specific to the module. There is no easy way to have it in action for all of your modules, without actually having a line in all of your modules.

, grep ( , ), , .

, importlib __import__. , .py,

from __future__ import absolute_import

( ), . , , , , , , , .

+2

All Articles