|
22 | 22 | can be inspected programmatically via importing :mod:`__future__` and examining
|
23 | 23 | its contents.
|
24 | 24 |
|
25 |
| -Each statement in :file:`__future__.py` is of the form:: |
| 25 | +.. _future-classes: |
26 | 26 |
|
27 |
| - FeatureName = _Feature(OptionalRelease, MandatoryRelease, |
28 |
| - CompilerFlag) |
| 27 | +.. class:: _Feature |
29 | 28 |
|
| 29 | + Each statement in :file:`__future__.py` is of the form:: |
30 | 30 |
|
31 |
| -where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both are |
32 |
| -5-tuples of the same form as :data:`sys.version_info`:: |
| 31 | + FeatureName = _Feature(OptionalRelease, MandatoryRelease, |
| 32 | + CompilerFlag) |
33 | 33 |
|
34 |
| - (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int |
35 |
| - PY_MINOR_VERSION, # the 1; an int |
36 |
| - PY_MICRO_VERSION, # the 0; an int |
37 |
| - PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string |
38 |
| - PY_RELEASE_SERIAL # the 3; an int |
39 |
| - ) |
| 34 | + where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both are |
| 35 | + 5-tuples of the same form as :data:`sys.version_info`:: |
40 | 36 |
|
41 |
| -*OptionalRelease* records the first release in which the feature was accepted. |
| 37 | + (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int |
| 38 | + PY_MINOR_VERSION, # the 1; an int |
| 39 | + PY_MICRO_VERSION, # the 0; an int |
| 40 | + PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string |
| 41 | + PY_RELEASE_SERIAL # the 3; an int |
| 42 | + ) |
42 | 43 |
|
43 |
| -In the case of a *MandatoryRelease* that has not yet occurred, |
44 |
| -*MandatoryRelease* predicts the release in which the feature will become part of |
45 |
| -the language. |
| 44 | +.. method:: _Feature.getOptionalRelease() |
46 | 45 |
|
47 |
| -Else *MandatoryRelease* records when the feature became part of the language; in |
48 |
| -releases at or after that, modules no longer need a future statement to use the |
49 |
| -feature in question, but may continue to use such imports. |
| 46 | + *OptionalRelease* records the first release in which the feature was accepted. |
50 | 47 |
|
51 |
| -*MandatoryRelease* may also be ``None``, meaning that a planned feature got |
52 |
| -dropped. |
| 48 | +.. method:: _Feature.getMandatoryRelease() |
53 | 49 |
|
54 |
| -Instances of class :class:`_Feature` have two corresponding methods, |
55 |
| -:meth:`getOptionalRelease` and :meth:`getMandatoryRelease`. |
| 50 | + In the case of a *MandatoryRelease* that has not yet occurred, |
| 51 | + *MandatoryRelease* predicts the release in which the feature will become part of |
| 52 | + the language. |
56 | 53 |
|
57 |
| -*CompilerFlag* is the (bitfield) flag that should be passed in the fourth |
58 |
| -argument to the built-in function :func:`compile` to enable the feature in |
59 |
| -dynamically compiled code. This flag is stored in the :attr:`compiler_flag` |
60 |
| -attribute on :class:`_Feature` instances. |
| 54 | + Else *MandatoryRelease* records when the feature became part of the language; in |
| 55 | + releases at or after that, modules no longer need a future statement to use the |
| 56 | + feature in question, but may continue to use such imports. |
| 57 | + |
| 58 | + *MandatoryRelease* may also be ``None``, meaning that a planned feature got |
| 59 | + dropped or that it is not yet decided. |
| 60 | + |
| 61 | +.. attribute:: _Feature.compiler_flag |
| 62 | + |
| 63 | + *CompilerFlag* is the (bitfield) flag that should be passed in the fourth |
| 64 | + argument to the built-in function :func:`compile` to enable the feature in |
| 65 | + dynamically compiled code. This flag is stored in the :attr:`_Feature.compiler_flag` |
| 66 | + attribute on :class:`_Feature` instances. |
61 | 67 |
|
62 | 68 | No feature description will ever be deleted from :mod:`__future__`. Since its
|
63 | 69 | introduction in Python 2.1 the following features have found their way into the
|
|
0 commit comments