GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • index
  • modules
  • next
  • Python-Future documentation
  • Table of Contents
  • Quick-start guide
  • Cheat Sheet: Writing Python 2-3 compatible code
  • Imports
  • What else you need to know
  • Automatic conversion to Py2/3
  • Frequently Asked Questions (FAQ)
  • Standard library incompatibilities
  • Older interfaces
  • Changes in previous versions

This view

  • Original page
  • New address

GeezerVison is showing python-future.org — Easy, clean, reliable Python 2/3 compatibility — Python-Future documentation

Easy, clean, reliable Python 2/3 compatibility¶

python-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.

Contents¶

  • What’s New
    • What’s new in version 1.0.0 (2024-02-21)
    • Previous versions
  • Overview: Easy, clean, reliable Python 2/3 compatibility
    • Status
    • Features
    • Code examples
    • Automatic conversion to Py2/3-compatible code
      • Futurize: 2 to both
      • Automatic translation
      • Pre-commit hooks
    • Licensing
    • Docs
    • Next steps
  • Quick-start guide
    • Installation
    • If you are writing code from scratch
    • To convert existing Python 3 code
    • To convert existing Python 2 code
    • Standard library reorganization
    • Python 2-only dependencies
    • Next steps
  • Cheat Sheet: Writing Python 2-3 compatible code
    • Setup
    • Essential syntax differences
      • print
      • Raising exceptions
      • Catching exceptions
      • Division
      • Long integers
      • Octal constants
      • Backtick repr
      • Metaclasses
    • Strings and bytes
      • Unicode (text) string literals
      • Byte-string literals
      • basestring
      • unicode
      • StringIO
    • Imports relative to a package
    • Dictionaries
      • Iterating through dict keys/values/items
      • dict keys/values/items as a list
    • Custom class behaviour
      • Custom iterators
      • Custom __str__ methods
      • Custom __nonzero__ vs __bool__ method:
    • Lists versus iterators
      • xrange
      • range
      • map
      • imap
      • zip, izip
      • filter, ifilter
    • Other builtins
      • File IO with open()
      • reduce()
      • raw_input()
      • input()
      • file()
      • exec
      • execfile()
      • unichr()
      • intern()
      • apply()
      • chr()
      • cmp()
      • reload()
    • Standard library
      • dbm modules
      • commands / subprocess modules
      • StringIO module
      • http module
      • xmlrpc module
      • html escaping and entities
      • html parsing
      • urllib module
      • Tkinter
      • socketserver
      • copy_reg, copyreg
      • configparser
      • queue
      • repr, reprlib
      • UserDict, UserList, UserString
      • itertools: filterfalse, zip_longest
  • Imports
    • __future__ imports
    • Imports of builtins
      • Implicit imports
      • Explicit imports
    • Standard library imports
      • Direct imports
      • Aliased imports
    • External standard-library backports
    • Included full backports
    • Using Python 2-only dependencies on Python 3
    • Should I import unicode_literals?
      • Benefits
      • Drawbacks
      • Others’ perspectives
    • Next steps
  • What else you need to know
    • bytes
    • str
    • dict
      • Memory-efficiency and alternatives
    • int
    • isinstance
    • Passing data to/from Python 2 libraries
    • Native string type
    • open()
    • Custom __str__ methods
    • Custom iterators
    • Binding a method to a class
    • Metaclasses
  • Automatic conversion to Py2/3
    • futurize: Py2 to Py2/3
      • Stage 1: “safe” fixes
      • Stage 2: Py3-style code with wrappers for Py2
      • Separating text from bytes
      • Post-conversion
    • futurize quick-start guide
      • Step 0: setup
      • Step 1: modern Py2 code
      • Step 2: working Py3 code that still supports Py2
    • pasteurize: Py3 to Py2/3
    • Known limitations
  • Frequently Asked Questions (FAQ)
    • Who is this for?
    • Why upgrade to Python 3?
    • Porting philosophy
      • Why write Python 3-style code?
      • Can’t I just roll my own Py2/3 compatibility layer?
      • What inspired this project?
    • Maturity
      • How well has it been tested?
      • Is the API stable?
    • Relationship between python-future and other compatibility tools
      • How does this relate to 2to3?
      • Can I maintain a Python 2 codebase and use 2to3 to automatically convert to Python 3 in the setup script?
      • What is the relationship between future and six?
      • What is the relationship between python-future and python-modernize?
    • Platform and version support
      • Which versions of Python does python-future support?
    • Support
      • Is there a mailing list?
    • Contributing
      • Can I help?
      • Where is the repo?
  • Standard library incompatibilities
    • array.array()
    • array.array.read()
    • base64.decodebytes() and base64.encodebytes()
    • re.ASCII
    • struct.pack()
  • Older interfaces
    • future.moves interface
      • Comparing future.moves and six.moves
    • import_ and from_import functions
    • Context-manager for import hooks
    • install_hooks() call (deprecated)
  • Changes in previous versions
    • Changes in version 0.18.3 (2023-01-13)
    • Changes in version 0.18.2 (2019-10-30)
    • Changes in version 0.18.1 (2019-10-09)
    • Changes in version 0.18.0 (2019-10-09)
    • Changes in version 0.17.1 (2018-10-30)
    • Changes in version 0.17.0 (2018-10-19)
    • Changes in version 0.16.0 (2016-10-27)
    • Changes in version 0.15.2 (2015-09-11)
    • Changes in version 0.15.1 (2015-09-09)
    • Changes in version 0.15.0 (2015-07-25)
    • Changes in version 0.14.3 (2014-12-15)
    • Changes in version 0.14.2 (2014-11-21)
    • Changes in version 0.14.1 (2014-10-02)
    • Changes in version 0.14.0 (2014-10-02)
      • Bug fixes
      • Internal cleanups
      • Deprecations
    • Changes in version 0.13.1 (2014-09-23)
    • Changes in version 0.13.0 (2014-08-13)
      • Deprecations
      • New features
      • Bug fixes
    • Changes in version 0.12.4 (2014-07-18)
    • Changes in version 0.12.3 (2014-06-19)
    • Changes in version 0.12.2 (2014-05-25)
    • Changes in version 0.12.1 (2014-05-14)
    • Changes in version 0.12.0 (2014-05-06)
      • More robust standard-library import hooks
      • newobject base object defines fallback Py2-compatible special methods
      • past.builtins module improved
      • surrogateescape error handler
      • newlist type
      • listvalues and listitems
      • Tests
      • Refactoring of future.standard_library.* -> future.backports
      • Backported http.server and urllib modules
      • Internal refactoring
      • Bug fixes
    • Changes in version 0.11.4 (2014-05-25)
    • Changes in version 0.11.3 (2014-02-27)
      • Improved compatibility with requests
      • Conversion scripts explicitly install import hooks
      • futurize script no longer adds unicode_literals by default
    • Changes in version 0.11 (2014-01-28)
      • past package
      • Auto-translation of Python 2 modules upon import
      • Separate pasteurize script
      • pow()
      • input() no longer disabled globally on Py2
      • Deprecated feature: auto-installation of standard-library import hooks
      • Internal changes
    • Changes in version 0.10.2 (2014-01-11)
      • New context-manager interface to standard_library.hooks
    • Changes in version 0.10.0 (2013-12-02)
      • Backported dict type
      • Utility functions raise_ and exec_
      • Bugfixes
    • Changes in version 0.9 (2013-11-06)
      • isinstance checks are supported natively with backported types
      • futurize: minimal imports by default
      • Looser type-checking for the backported str object
      • suspend_hooks() context manager added to future.standard_library
    • Changes in version 0.8 (2013-10-28)
      • Python 2.6 support
      • Unused modules removed
      • isinstance() added to future.builtins (v0.8.2)
    • Summary of all changes
  • Licensing and credits
    • Licence
    • Sponsors
    • Author
    • Maintainers
    • Contributors
      • Suggestions and Feedback
    • Other Credits
  • API Reference (in progress)
    • future.builtins Interface
    • Backported types from Python 3
      • For more information:
      • range()
      • super()
      • round()
    • future.standard_library Interface
      • Limitations
      • RenameImport
      • cache_py2_modules()
      • detect_hooks()
      • disable_hooks()
      • enable_hooks()
      • exclude_local_folder_imports
      • from_import()
      • hooks
      • import_()
      • install_aliases()
      • install_hooks()
      • is_py2_stdlib_module()
      • remove_hooks()
      • restore_sys_modules()
      • scrub_future_sys_modules()
      • scrub_py2_sys_modules()
      • suspend_hooks
    • future.utils Interface
      • as_native_str()
      • binary_type
      • bind_method()
      • exec_()
      • implements_iterator()
      • is_new_style()
      • isbytes()
      • isidentifier()
      • isint()
      • isnewbytes()
      • istext()
      • iteritems()
      • iterkeys()
      • itervalues()
      • native()
      • native_bytes
      • native_str
      • native_str_to_bytes()
      • old_div()
      • python_2_unicode_compatible()
      • raise_()
      • raise_with_traceback()
      • reraise()
      • text_type
      • tobytes()
      • viewitems()
      • viewkeys()
      • viewvalues()
      • with_metaclass()
    • past.builtins Interface
      • basestring
      • chr()
      • cmp()
      • dict
      • execfile()
      • filter()
      • intern()
      • long
      • map()
      • raw_input()
      • reduce()
      • reload()
      • str
      • unichr()
      • unicode
      • xrange
    • Forward-ported types from Python 2
      • basestring
      • long
      • olddict
      • oldstr
      • unicode

Indices and tables¶

  • Index

  • Module Index

  • Search Page

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.