PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation_files/__future__.py

https://github.com/kensington/kdevelop-python
Python | 88 lines | 61 code | 16 blank | 11 comment | 7 complexity | e51c917620dbc0f54643417686f2a9c9 MD5 | raw file
  1. #!/usr/bin/env python2.7
  2. # -*- coding: utf-8 -*-
  3. """:synopsis: Future statement definitions
  4. :mod:`__future__` is a real module, and serves three purposes:
  5. * To avoid confusing existing tools that analyze import statements and expect to
  6. find the modules they're importing.
  7. * To ensure that :ref:`future statements <future>` run under releases prior to
  8. 2.1 at least yield runtime exceptions (the import of :mod:`__future__` will
  9. fail, because there was no module of that name prior to 2.1).
  10. * To document when incompatible changes were introduced, and when they will be
  11. --- or were --- made mandatory. This is a form of executable documentation, and
  12. can be inspected programmatically via importing :mod:`__future__` and examining
  13. its contents.
  14. Each statement in :file:`__future__.py` is of the form::
  15. FeatureName = _Feature(OptionalRelease, MandatoryRelease,
  16. CompilerFlag)
  17. where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both are
  18. 5-tuples of the same form as ``sys.version_info``::
  19. (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
  20. PY_MINOR_VERSION, # the 1; an int
  21. PY_MICRO_VERSION, # the 0; an int
  22. PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
  23. PY_RELEASE_SERIAL # the 3; an int
  24. )
  25. *OptionalRelease* records the first release in which the feature was accepted.
  26. In the case of a *MandatoryRelease* that has not yet occurred,
  27. *MandatoryRelease* predicts the release in which the feature will become part of
  28. the language.
  29. Else *MandatoryRelease* records when the feature became part of the language; in
  30. releases at or after that, modules no longer need a future statement to use the
  31. feature in question, but may continue to use such imports.
  32. *MandatoryRelease* may also be ``None``, meaning that a planned feature got
  33. dropped.
  34. Instances of class :class:`_Feature` have two corresponding methods,
  35. :meth:`getOptionalRelease` and :meth:`getMandatoryRelease`.
  36. *CompilerFlag* is the (bitfield) flag that should be passed in the fourth
  37. argument to the built-in function :func:`compile` to enable the feature in
  38. dynamically compiled code. This flag is stored in the :attr:`compiler_flag`
  39. attribute on :class:`_Feature` instances.
  40. No feature description will ever be deleted from :mod:`__future__`. Since its
  41. introduction in Python 2.1 the following features have found their way into the
  42. language using this mechanism:
  43. +------------------+-------------+--------------+---------------------------------------------+
  44. | feature | optional in | mandatory in | effect |
  45. +==================+=============+==============+=============================================+
  46. | nested_scopes | 2.1.0b1 | 2.2 | :pep:`227`: |
  47. | | | | *Statically Nested Scopes* |
  48. +------------------+-------------+--------------+---------------------------------------------+
  49. | generators | 2.2.0a1 | 2.3 | :pep:`255`: |
  50. | | | | *Simple Generators* |
  51. +------------------+-------------+--------------+---------------------------------------------+
  52. | division | 2.2.0a2 | 3.0 | :pep:`238`: |
  53. | | | | *Changing the Division Operator* |
  54. +------------------+-------------+--------------+---------------------------------------------+
  55. | absolute_import | 2.5.0a1 | 2.7 | :pep:`328`: |
  56. | | | | *Imports: Multi-Line and Absolute/Relative* |
  57. +------------------+-------------+--------------+---------------------------------------------+
  58. | with_statement | 2.5.0a1 | 2.6 | :pep:`343`: |
  59. | | | | *The "with" Statement* |
  60. +------------------+-------------+--------------+---------------------------------------------+
  61. | print_function | 2.6.0a2 | 3.0 | :pep:`3105`: |
  62. | | | | *Make print a function* |
  63. +------------------+-------------+--------------+---------------------------------------------+
  64. | unicode_literals | 2.6.0a2 | 3.0 | :pep:`3112`: |
  65. | | | | *Bytes literals in Python 3000* |
  66. +------------------+-------------+--------------+---------------------------------------------+
  67. """
  68. def print_function(): pass