future

Clean single-source support for Python 3 and 2

MIT 52 个版本 Python >=2.6, !=3.0.*, !=3.1.*, !=3.2.*
Ed Schofield <ed@pythoncharmers.com>
安装
pip install future
poetry add future
pipenv install future
conda install future
描述

future: Easy, safe support for Python 2/3 compatibility

future is the missing compatibility layer between Python 2 and Python 3. It allows you to use a single, clean Python 3.x-compatible codebase to support both Python 2 and Python 3 with minimal overhead.

It is designed to be used as follows::

from __future__ import (absolute_import, division,
                        print_function, unicode_literals)
from builtins import (
         bytes, dict, int, list, object, range, str,
         ascii, chr, hex, input, next, oct, open,
         pow, round, super,
         filter, map, zip)

followed by predominantly standard, idiomatic Python 3 code that then runs similarly on Python 2.6/2.7 and Python 3.3+.

The imports have no effect on Python 3. On Python 2, they shadow the corresponding builtins, which normally have different semantics on Python 3 versus 2, to provide their Python 3 semantics.

Standard library reorganization


``future`` supports the standard library reorganization (PEP 3108) through the
following Py3 interfaces:

    >>> # Top-level packages with Py3 names provided on Py2:
    >>> import html.parser
    >>> import queue
    >>> import tkinter.dialog
    >>> import xmlrpc.client
    >>> # etc.

    >>> # Aliases provided for extensions to existing Py2 module names:
    >>> from future.standard_library import install_aliases
    >>> install_aliases()

    >>> from collections import Counter, OrderedDict   # backported to Py2.6
    >>> from collections import UserDict, UserList, UserString
    >>> import urllib.request
    >>> from itertools import filterfalse, zip_longest
    >>> from subprocess import getoutput, getstatusoutput


Automatic conversion
--------------------

An included script called `futurize
<https://python-future.org/automatic_conversion.html>`_ aids in converting
code (from either Python 2 or Python 3) to code compatible with both
platforms. It is similar to ``python-modernize`` but goes further in
providing Python 3 compatibility through the use of the backported types
and builtin functions in ``future``.


Documentation
-------------

See: https://python-future.org


Credits
-------

:Author:  Ed Schofield, Jordan M. Adler, et al
:Sponsor: Python Charmers: https://pythoncharmers.com
:Others:  See docs/credits.rst or https://python-future.org/credits.html


Licensing
---------
Copyright 2013-2024 Python Charmers, Australia.
The software is distributed under an MIT licence. See LICENSE.txt.

版本列表
1.0.0 2024-02-21
0.18.3 2023-01-13
0.18.2 2019-10-31
0.18.1 2019-10-17
0.18.0 2020-11-24
0.17.1 2018-10-31
0.17.0 2018-10-25
0.16.0 2016-10-27
0.15.2 2015-09-11
0.15.1 2015-09-09
0.15.0 2015-07-25
0.14.3 2014-12-14
0.14.2 2014-11-21
0.14.1 2014-10-02
0.14.0 2014-10-02
0.13.1 2014-09-23
0.13.0 2014-08-13
0.12.4 2014-07-18
0.12.3 2014-06-19
0.12.2 2014-05-25
0.12.1 2014-05-14
0.12.0 2014-05-05
0.11.4 2014-03-24
0.11.3 2014-02-28
0.11.2 2014-01-28
0.11.1 2014-01-28
0.11.0 2014-01-28
0.10.2 2014-01-11
0.10.1 2013-12-07
0.10.0 2013-12-01
0.9.0 2013-11-15
0.8.2 2013-10-30
0.8.1 2013-10-29
0.8.0 2013-10-28
0.7.0 2013-10-24
0.6.0 2013-10-02
0.5.2 2013-09-24
0.5.1 2013-09-21
0.5.0 2013-09-18
0.4.1 2013-09-12
0.4.0 2013-08-09
0.3.5 2013-08-08
0.3.4 2013-08-08
0.3.3 2013-08-05
0.3.2 2013-08-04
0.3.1 2013-08-04
0.3.0 2013-07-28
0.2.0 2013-07-26
0.1.0 2013-07-22
0.0.3 2013-07-21
0.0.2 2013-07-20
0.0.1 2013-07-14