Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/future/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1""" 

2future: Easy, safe support for Python 2/3 compatibility 

3======================================================= 

4 

5``future`` is the missing compatibility layer between Python 2 and Python 

63. It allows you to use a single, clean Python 3.x-compatible codebase to 

7support both Python 2 and Python 3 with minimal overhead. 

8 

9It is designed to be used as follows:: 

10 

11 from __future__ import (absolute_import, division, 

12 print_function, unicode_literals) 

13 from builtins import ( 

14 bytes, dict, int, list, object, range, str, 

15 ascii, chr, hex, input, next, oct, open, 

16 pow, round, super, 

17 filter, map, zip) 

18 

19followed by predominantly standard, idiomatic Python 3 code that then runs 

20similarly on Python 2.6/2.7 and Python 3.3+. 

21 

22The imports have no effect on Python 3. On Python 2, they shadow the 

23corresponding builtins, which normally have different semantics on Python 3 

24versus 2, to provide their Python 3 semantics. 

25 

26 

27Standard library reorganization 

28~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

29 

30``future`` supports the standard library reorganization (PEP 3108) through the 

31following Py3 interfaces: 

32 

33 >>> # Top-level packages with Py3 names provided on Py2: 

34 >>> import html.parser 

35 >>> import queue 

36 >>> import tkinter.dialog 

37 >>> import xmlrpc.client 

38 >>> # etc. 

39 

40 >>> # Aliases provided for extensions to existing Py2 module names: 

41 >>> from future.standard_library import install_aliases 

42 >>> install_aliases() 

43 

44 >>> from collections import Counter, OrderedDict # backported to Py2.6 

45 >>> from collections import UserDict, UserList, UserString 

46 >>> import urllib.request 

47 >>> from itertools import filterfalse, zip_longest 

48 >>> from subprocess import getoutput, getstatusoutput 

49 

50 

51Automatic conversion 

52-------------------- 

53 

54An included script called `futurize 

55<https://python-future.org/automatic_conversion.html>`_ aids in converting 

56code (from either Python 2 or Python 3) to code compatible with both 

57platforms. It is similar to ``python-modernize`` but goes further in 

58providing Python 3 compatibility through the use of the backported types 

59and builtin functions in ``future``. 

60 

61 

62Documentation 

63------------- 

64 

65See: https://python-future.org 

66 

67 

68Credits 

69------- 

70 

71:Author: Ed Schofield, Jordan M. Adler, et al 

72:Sponsor: Python Charmers: https://pythoncharmers.com 

73:Others: See docs/credits.rst or https://python-future.org/credits.html 

74 

75 

76Licensing 

77--------- 

78Copyright 2013-2024 Python Charmers, Australia. 

79The software is distributed under an MIT licence. See LICENSE.txt. 

80 

81""" 

82 

83__title__ = 'future' 

84__author__ = 'Ed Schofield' 

85__license__ = 'MIT' 

86__copyright__ = 'Copyright 2013-2024 Python Charmers (https://pythoncharmers.com)' 

87__ver_major__ = 1 

88__ver_minor__ = 0 

89__ver_patch__ = 0 

90__ver_sub__ = '' 

91__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__, 

92 __ver_patch__, __ver_sub__)