{
    "content": [
        {
            "type": "text",
            "text": "# past (pydoc)\n\n**Summary:** past\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (83 lines)\n- **PACKAGE CONTENTS** (5 lines)\n- **DATA** (4 lines)\n- **VERSION** (2 lines)\n- **AUTHOR** (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\npast\n\n### DESCRIPTION\n\npast: compatibility with Python 2 from Python 3\n===============================================\n\n``past`` is a package to aid with Python 2/3 compatibility. Whereas ``future``\ncontains backports of Python 3 constructs to Python 2, ``past`` provides\nimplementations of some Python 2 constructs in Python 3 and tools to import and\nrun Python 2 code in Python 3. It is intended to be used sparingly, as a way of\nrunning old Python 2 code from Python 3 until the code is ported properly.\n\nPotential uses for libraries:\n\n- as a step in porting a Python 2 codebase to Python 3 (e.g. with the ``futurize`` script)\n- to provide Python 3 support for previously Python 2-only libraries with the\nsame APIs as on Python 2 -- particularly with regard to 8-bit strings (the\n``past.builtins.str`` type).\n- to aid in providing minimal-effort Python 3 support for applications using\nlibraries that do not yet wish to upgrade their code properly to Python 3, or\nwish to upgrade it gradually to Python 3 style.\n\n\nHere are some code examples that run identically on Python 3 and 2::\n\n>>> from past.builtins import str as oldstr\n\n>>> philosopher = oldstr(u'孔子'.encode('utf-8'))\n>>> # This now behaves like a Py2 byte-string on both Py2 and Py3.\n>>> # For example, indexing returns a Python 2-like string object, not\n>>> # an integer:\n>>> philosopher[0]\n'å'\n>>> type(philosopher[0])\n<past.builtins.oldstr>\n\n>>> # List-producing versions of range, reduce, map, filter\n>>> from past.builtins import range, reduce\n>>> range(10)\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n>>> reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])\n15\n\n>>> # Other functions removed in Python 3 are resurrected ...\n>>> from past.builtins import execfile\n>>> execfile('myfile.py')\n\n>>> from past.builtins import rawinput\n>>> name = rawinput('What is your name? ')\nWhat is your name? [cursor]\n\n>>> from past.builtins import reload\n>>> reload(mymodule)   # equivalent to imp.reload(mymodule) in Python 3\n\n>>> from past.builtins import xrange\n>>> for i in xrange(10):\n...     pass\n\n\nIt also provides import hooks so you can import and use Python 2 modules like\nthis::\n\n$ python3\n\n>>> from past.translation import autotranslate\n>>> authotranslate('mypy2module')\n>>> import mypy2module\n\nuntil the authors of the Python 2 modules have upgraded their code. Then, for\nexample::\n\n>>> mypy2module.functakingpy2string(oldstr(b'abcd'))\n\n\nCredits\n-------\n\n:Author:  Ed Schofield, Jordan M. Adler, et al\n:Sponsor: Python Charmers Pty Ltd, Australia: http://pythoncharmers.com\n\n\nLicensing\n---------\nCopyright 2013-2019 Python Charmers Pty Ltd, Australia.\nThe software is distributed under an MIT licence. See LICENSE.txt.\n\n### PACKAGE CONTENTS\n\nbuiltins (package)\ntranslation (package)\ntypes (package)\nutils (package)\n\n### DATA\n\ncopyright = 'Copyright 2013-2019 Python Charmers Pty Ltd'\nlicense = 'MIT'\ntitle = 'past'\n\n### VERSION\n\n0.18.2\n\n### AUTHOR\n\nEd Schofield\n\n### FILE\n\n/usr/lib/python3/dist-packages/past/init.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "past",
        "section": "",
        "mode": "pydoc",
        "summary": "past",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 83,
                "subsections": []
            },
            {
                "name": "PACKAGE CONTENTS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DATA",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}