__init__.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. A module that brings in equivalents of the new and modified Python 3
  3. builtins into Py2. Has no effect on Py3.
  4. See the docs `here <http://python-future.org/what-else.html>`_
  5. (``docs/what-else.rst``) for more information.
  6. """
  7. from future.builtins.iterators import (filter, map, zip)
  8. # The isinstance import is no longer needed. We provide it only for
  9. # backward-compatibility with future v0.8.2. It will be removed in future v1.0.
  10. from future.builtins.misc import (ascii, chr, hex, input, isinstance, next,
  11. oct, open, pow, round, super, max, min)
  12. from future.utils import PY3
  13. if PY3:
  14. import builtins
  15. bytes = builtins.bytes
  16. dict = builtins.dict
  17. int = builtins.int
  18. list = builtins.list
  19. object = builtins.object
  20. range = builtins.range
  21. str = builtins.str
  22. __all__ = []
  23. else:
  24. from future.types import (newbytes as bytes,
  25. newdict as dict,
  26. newint as int,
  27. newlist as list,
  28. newobject as object,
  29. newrange as range,
  30. newstr as str)
  31. from future import utils
  32. if not utils.PY3:
  33. # We only import names that shadow the builtins on Py2. No other namespace
  34. # pollution on Py2.
  35. # Only shadow builtins on Py2; no new names
  36. __all__ = ['filter', 'map', 'zip',
  37. 'ascii', 'chr', 'hex', 'input', 'next', 'oct', 'open', 'pow',
  38. 'round', 'super',
  39. 'bytes', 'dict', 'int', 'list', 'object', 'range', 'str', 'max', 'min'
  40. ]
  41. else:
  42. # No namespace pollution on Py3
  43. __all__ = []