future is a real module, and serves three purposes:
To avoid confusing existing tools that analyze import statements and expect to find the modules they’re importing.
To ensure that future statements run under releases prior to 2.1 at least yield runtime exceptions (the import of future will fail, because there was no module of that name prior to 2.1).
To document when incompatible changes were introduced, and when they will be — or were — made mandatory. This is a form of executable documentation, and can be inspected programmatically via importing future and examining its contents.
# still running on Python 2.7from__future__import unicode_literalsprint'\'xxx\' is unicode?',isinstance('xxx', unicode)print'u\'xxx\' is unicode?',isinstance(u'xxx', unicode)print'\'xxx\' is str?',isinstance('xxx', str)print'b\'xxx\' is str?',isinstance(b'xxx', str)
$ python3Python 3.3.2 (default, Jan 222014,09:54:40) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwinType "help","copyright","credits"or"license"for more information.>>>10/33.3333333333333335>>>10//33