>> from past.builtins import str as oldstr >>> philosopher = oldstr(u'孔子'.encode('utf-8')) >>> # This now behaves like a Py2 byte-string on both Py2 and Py3. >>> # For example, indexing returns a Python 2-like string object, not >>> # an integer: >>> philosopher[0] 'å' >>> type(philosopher[0]) >>> # List-producing versions of range, reduce, map, filter >>> from past.builtins import range, reduce >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) 15 >>> # Other functions removed in Python 3 are resurrected ... >>> from past.builtins import execfile >>> execfile('myfile.py') >>> from past.builtins import raw_input >>> name = raw_input('What is your name? ') What is your name? [cursor] >>> from past.builtins import reload >>> reload(mymodule) # equivalent to imp.reload(mymodule) in Python 3 >>> from past.builtins import xrange >>> for i in xrange(10): ... pass It also provides import hooks so you can import and use Python 2 modules like this:: $ python3 >>> from past.translation import autotranslate >>> authotranslate('mypy2module') >>> import mypy2module until the authors of the Python 2 modules have upgraded their code. Then, for example:: >>> mypy2module.func_taking_py2_string(oldstr(b'abcd')) Credits ------- :Author: Ed Schofield, Jordan M. Adler, et al :Sponsor: Python Charmers Pty Ltd, Australia: http://pythoncharmers.com Licensing --------- Copyright 2013-2019 Python Charmers Pty Ltd, Australia. The software is distributed under an MIT licence. See LICENSE.txt. ) __version__ __copyright__ __license__pastz Ed SchofieldN)__doc__futurerrr __title__ __author___/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/past/__init__.pyrs@SSj;:::::::::   r