{ "info": { "author": "Ed Schofield", "author_email": "ed@pythoncharmers.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "past: an implementation of Python 2 constructs in Python 3\r\n==========================================================\r\n\r\n``past`` is a package to aid with Python 2/3 compatibility. Whereas ``future``\r\ncontains backports of Python 3 constructs to Python 2, ``past`` provides\r\nimplementations of some Python 2 constructs in Python 3. It is intended to be\r\nused sparingly, as a way of running old Python 2 code from Python 3 until it is\r\nported properly.\r\n\r\nPotential uses for libraries:\r\n\r\n- as a step in porting a Python 2 codebase to Python 3 (e.g. with the ``futurize`` script)\r\n- to provide Python 3 support for previously Python 2-only libraries with the\r\n same APIs as on Python 2 -- particularly with regard to 8-bit strings (the\r\n ``past.builtins.str`` type).\r\n- to aid in providing minimal-effort Python 3 support for applications using\r\n libraries that do not yet wish to upgrade their code properly to Python 3, or\r\n wish to upgrade it gradually to Python 3 style.\r\n\r\nTo install ``past``, use::\r\n\r\n $ pip install future\r\n\r\nHere are some examples that run identically on Python 3 and 2::\r\n\r\n >>> from past.builtins import (str as oldstr, range, reduce,\r\n raw_input, xrange)\r\n\r\n >>> philosopher = oldstr(u'\u5b54\u5b50'.encode('utf-8'))\r\n >>> # This now behaves like a Py2 byte-string on both Py2 and Py3.\r\n >>> # For example, indexing returns a Python 2-like string object, not\r\n >>> # an integer:\r\n >>> philosopher[0]\r\n '\u00e5'\r\n >>> type(philosopher[0])\r\n \r\n\r\n >>> # The div() function behaves like Python 2's / operator\r\n >>> # without \"from __future__ import division\"\r\n >>> from past.utils import div\r\n >>> div(3, 2) # like 3/2 in Py2\r\n 0\r\n >>> div(3, 2.0) # like 3/2.0 in Py2\r\n 1.5\r\n\r\n >>> # List-producing versions of range, reduce, map, filter\r\n >>> from past.builtins import range, reduce\r\n >>> range(10)\r\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\r\n >>> reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])\r\n 15\r\n\r\n >>> # Other functions removed in Python 3 are resurrected ...\r\n >>> from past.builtins import execfile\r\n >>> execfile('myfile.py')\r\n\r\n >>> from past.builtins import raw_input\r\n >>> name = raw_input('What is your name? ')\r\n What is your name? [cursor]\r\n\r\n >>> from past.builtins import reload\r\n >>> reload(mymodule) # equivalent to imp.reload(mymodule) in Python 3\r\n\r\n >>> from past.builtins import xrange\r\n >>> for i in xrange(10):\r\n ... pass\r\n\r\n\r\nIt also provides experimental import hooks so you can import and run Python 2 modules from Python 3::\r\n\r\n >>> from past import autotranslate\r\n >>> autotranslate('mypy2module')\r\n\r\n >>> import mypy2module\r\n\r\n\r\nDocumentation\r\n-------------\r\n\r\nSee http://python-future.org.\r\n\r\n\r\nCredits\r\n-------\r\n\r\n:Author: Ed Schofield\r\n:Sponsor: Python Charmers Pty Ltd, Australia: http://pythoncharmers.com\r\n\r\n\r\nLicensing\r\n---------\r\nCopyright 2013-2014 Python Charmers Pty Ltd, Australia.\r\nThe software is distributed under an MIT licence. See LICENSE.txt.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PythonCharmers/python-future", "keywords": "past future python3 python2 migration backport six 2to3 pasteurize modernize", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "past", "package_url": "https://pypi.org/project/past/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/past/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/PythonCharmers/python-future" }, "release_url": "https://pypi.org/project/past/0.11.1/", "requires_dist": null, "requires_python": null, "summary": "[Experimental] Run Python 2 code from Python 3", "version": "0.11.1" }, "last_serial": 984092, "releases": { "0.11.1": [] }, "urls": [] }