Python-Future: Advanced 2/3 Compatibility with Python 3 Style

The 'python-future' library, with its 'futurize' and 'pasteurize' tools, offers a higher-level compatibility layer than 'six', enabling standard Python 3 code to run on Python 2 with minimal changes. It backports Python 3 features and forward-ports Python 2 features, promoting a cleaner Python 3-style codebase.

The top 3

  1. Python-Future vs. Six: Key Compatibility Differences: While `six` primarily offers minimal compatibility shims for Python 2 and 3, `python-future` aims to backport Python 3 features to Python 2, allowing developers to write Python 3-idiomatic code that runs on both versions. `python-future`'s `future.moves` uses real Python packages, potentially offering more robustness than `six.moves`'s fake `_LazyModule` objects.
  2. Top 3 Python 3 Features Backported by Future: `python-future`'s `future.builtins` package provides backports and remappings for 20 built-in functions and types with different semantics. Key backported features enabling Python 3 style in Python 2 include the `print()` function, true division (`/`), and `unicode_literals` (via `__future__` imports), which significantly eased migration efforts.
  3. Python-Future's Genesis: Averting Python's "Schism": The `python-future` project was created in 2013 to prevent Python from experiencing a version incompatibility "schism" similar to Perl 6, by providing a compatibility layer that enabled a single, clean Python 3.x-compatible codebase to support both Python 2 and Python 3.

Sources

Open the full topic