OLD | NEW |
(Empty) | |
| 1 """ |
| 2 future: Easy, safe support for Python 2/3 compatibility |
| 3 ======================================================= |
| 4 |
| 5 ``future`` is the missing compatibility layer between Python 2 and Python |
| 6 3. It allows you to use a single, clean Python 3.x-compatible codebase to |
| 7 support both Python 2 and Python 3 with minimal overhead. |
| 8 |
| 9 It is designed to be used as follows:: |
| 10 |
| 11 from __future__ import (absolute_import, division, |
| 12 print_function, unicode_literals) |
| 13 from builtins import ( |
| 14 bytes, dict, int, list, object, range, str, |
| 15 ascii, chr, hex, input, next, oct, open, |
| 16 pow, round, super, |
| 17 filter, map, zip) |
| 18 |
| 19 followed by predominantly standard, idiomatic Python 3 code that then runs |
| 20 similarly on Python 2.6/2.7 and Python 3.3+. |
| 21 |
| 22 The imports have no effect on Python 3. On Python 2, they shadow the |
| 23 corresponding builtins, which normally have different semantics on Python 3 |
| 24 versus 2, to provide their Python 3 semantics. |
| 25 |
| 26 |
| 27 Standard library reorganization |
| 28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 29 |
| 30 ``future`` supports the standard library reorganization (PEP 3108) through the |
| 31 following Py3 interfaces: |
| 32 |
| 33 >>> # Top-level packages with Py3 names provided on Py2: |
| 34 >>> import html.parser |
| 35 >>> import queue |
| 36 >>> import tkinter.dialog |
| 37 >>> import xmlrpc.client |
| 38 >>> # etc. |
| 39 |
| 40 >>> # Aliases provided for extensions to existing Py2 module names: |
| 41 >>> from future.standard_library import install_aliases |
| 42 >>> install_aliases() |
| 43 |
| 44 >>> from collections import Counter, OrderedDict # backported to Py2.6 |
| 45 >>> from collections import UserDict, UserList, UserString |
| 46 >>> import urllib.request |
| 47 >>> from itertools import filterfalse, zip_longest |
| 48 >>> from subprocess import getoutput, getstatusoutput |
| 49 |
| 50 |
| 51 Automatic conversion |
| 52 -------------------- |
| 53 |
| 54 An included script called `futurize |
| 55 <http://python-future.org/automatic_conversion.html>`_ aids in converting |
| 56 code (from either Python 2 or Python 3) to code compatible with both |
| 57 platforms. It is similar to ``python-modernize`` but goes further in |
| 58 providing Python 3 compatibility through the use of the backported types |
| 59 and builtin functions in ``future``. |
| 60 |
| 61 |
| 62 Documentation |
| 63 ------------- |
| 64 |
| 65 See: http://python-future.org |
| 66 |
| 67 |
| 68 Credits |
| 69 ------- |
| 70 |
| 71 :Author: Ed Schofield |
| 72 :Sponsor: Python Charmers Pty Ltd, Australia, and Python Charmers Pte |
| 73 Ltd, Singapore. http://pythoncharmers.com |
| 74 :Others: See docs/credits.rst or http://python-future.org/credits.html |
| 75 |
| 76 |
| 77 Licensing |
| 78 --------- |
| 79 Copyright 2013-2016 Python Charmers Pty Ltd, Australia. |
| 80 The software is distributed under an MIT licence. See LICENSE.txt. |
| 81 |
| 82 """ |
| 83 |
| 84 __title__ = 'future' |
| 85 __author__ = 'Ed Schofield' |
| 86 __license__ = 'MIT' |
| 87 __copyright__ = 'Copyright 2013-2016 Python Charmers Pty Ltd' |
| 88 __ver_major__ = 0 |
| 89 __ver_minor__ = 16 |
| 90 __ver_patch__ = 0 |
| 91 __ver_sub__ = '' |
| 92 __version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__, |
| 93 __ver_patch__, __ver_sub__) |
OLD | NEW |