Can I use "from __future__ import unicode_literals" in the main import file?

I am creating several Python demo scripts that should work under 2.6, 2.7, and 3.3.

As part of this, each module has a prefix

from __future__ import unicode_literals 

Is it possible to issue this directive from each of the modules and paste it into the general import file?

eg.

 # master.py from __future__ import unicode_literals # file1.py import master # file2.py import master 
+7
python
source share
2 answers

Not. Indication of documentation:

The future operator is a directive for the compiler to state that a particular module must be compiled using the syntax or semantics that will be available in the specified future version of Python.

( http://docs.python.org/2/reference/simple_stmts.html#future )

Import __feature__ affects only the current module.

+5
source share

Not. Compiler flags (as implemented by __future__ ) affect only the compilation of the current module.

+2
source share

All Articles