OLD | NEW |
(Empty) | |
| 1 """ |
| 2 A resurrection of some old functions from Python 2 for use in Python 3. These |
| 3 should be used sparingly, to help with porting efforts, since code using them |
| 4 is no longer standard Python 3 code. |
| 5 |
| 6 This module provides the following: |
| 7 |
| 8 1. Implementations of these builtin functions which have no equivalent on Py3: |
| 9 |
| 10 - apply |
| 11 - chr |
| 12 - cmp |
| 13 - execfile |
| 14 |
| 15 2. Aliases: |
| 16 |
| 17 - intern <- sys.intern |
| 18 - raw_input <- input |
| 19 - reduce <- functools.reduce |
| 20 - reload <- imp.reload |
| 21 - unichr <- chr |
| 22 - unicode <- str |
| 23 - xrange <- range |
| 24 |
| 25 3. List-producing versions of the corresponding Python 3 iterator-producing func
tions: |
| 26 |
| 27 - filter |
| 28 - map |
| 29 - range |
| 30 - zip |
| 31 |
| 32 4. Forward-ported Py2 types: |
| 33 |
| 34 - basestring |
| 35 - dict |
| 36 - str |
| 37 - long |
| 38 - unicode |
| 39 |
| 40 """ |
| 41 |
| 42 from future.utils import PY3 |
| 43 from past.builtins.noniterators import (filter, map, range, reduce, zip) |
| 44 # from past.builtins.misc import (ascii, hex, input, oct, open) |
| 45 if PY3: |
| 46 from past.types import (basestring, |
| 47 olddict as dict, |
| 48 oldstr as str, |
| 49 long, |
| 50 unicode) |
| 51 else: |
| 52 from __builtin__ import (basestring, dict, str, long, unicode) |
| 53 |
| 54 from past.builtins.misc import (apply, chr, cmp, execfile, intern, oct, |
| 55 raw_input, reload, unichr, unicode, xrange) |
| 56 from past import utils |
| 57 |
| 58 |
| 59 if utils.PY3: |
| 60 # We only import names that shadow the builtins on Py3. No other namespace |
| 61 # pollution on Py3. |
| 62 |
| 63 # Only shadow builtins on Py3; no new names |
| 64 __all__ = ['filter', 'map', 'range', 'reduce', 'zip', |
| 65 'basestring', 'dict', 'str', 'long', 'unicode', |
| 66 'apply', 'chr', 'cmp', 'execfile', 'intern', 'raw_input', |
| 67 'reload', 'unichr', 'xrange' |
| 68 ] |
| 69 |
| 70 else: |
| 71 # No namespace pollution on Py2 |
| 72 __all__ = [] |
OLD | NEW |