I'm creating some demonstration Python scripts that must work under 2.6, 2.7, and 3.3.
As part of that, each module is prefixed with
from __future__ import unicode_literals
Can this directive be cut from each of the modules and pasted into a common import file instead?
E.g.
# master.py
from __future__ import unicode_literals
# file1.py
import master
# file2.py
import master
No. Quoting 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.
(http://docs.python.org/2/reference/simple_stmts.html#future)
The __feature__
imports affect only the current module.
No. Compiler flags (which is how __future__
is implemented) only affect compilation of the current module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With