PyXR

c:\python24\lib \ __future__.py



0001 """Record of phased-in incompatible language changes.
0002 
0003 Each line is of the form:
0004 
0005     FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ","
0006                               CompilerFlag ")"
0007 
0008 where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
0009 of the same form as sys.version_info:
0010 
0011     (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
0012      PY_MINOR_VERSION, # the 1; an int
0013      PY_MICRO_VERSION, # the 0; an int
0014      PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
0015      PY_RELEASE_SERIAL # the 3; an int
0016     )
0017 
0018 OptionalRelease records the first release in which
0019 
0020     from __future__ import FeatureName
0021 
0022 was accepted.
0023 
0024 In the case of MandatoryReleases that have not yet occurred,
0025 MandatoryRelease predicts the release in which the feature will become part
0026 of the language.
0027 
0028 Else MandatoryRelease records when the feature became part of the language;
0029 in releases at or after that, modules no longer need
0030 
0031     from __future__ import FeatureName
0032 
0033 to use the feature in question, but may continue to use such imports.
0034 
0035 MandatoryRelease may also be None, meaning that a planned feature got
0036 dropped.
0037 
0038 Instances of class _Feature have two corresponding methods,
0039 .getOptionalRelease() and .getMandatoryRelease().
0040 
0041 CompilerFlag is the (bitfield) flag that should be passed in the fourth
0042 argument to the builtin function compile() to enable the feature in
0043 dynamically compiled code.  This flag is stored in the .compiler_flag
0044 attribute on _Future instances.  These values must match the appropriate
0045 #defines of CO_xxx flags in Include/compile.h.
0046 
0047 No feature line is ever to be deleted from this file.
0048 """
0049 
0050 all_feature_names = [
0051     "nested_scopes",
0052     "generators",
0053     "division",
0054 ]
0055 
0056 __all__ = ["all_feature_names"] + all_feature_names
0057 
0058 # The CO_xxx symbols are defined here under the same names used by
0059 # compile.h, so that an editor search will find them here.  However,
0060 # they're not exported in __all__, because they don't really belong to
0061 # this module.
0062 CO_NESTED            = 0x0010   # nested_scopes
0063 CO_GENERATOR_ALLOWED = 0x1000   # generators
0064 CO_FUTURE_DIVISION   = 0x2000   # division
0065 
0066 class _Feature:
0067     def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
0068         self.optional = optionalRelease
0069         self.mandatory = mandatoryRelease
0070         self.compiler_flag = compiler_flag
0071 
0072     def getOptionalRelease(self):
0073         """Return first release in which this feature was recognized.
0074 
0075         This is a 5-tuple, of the same form as sys.version_info.
0076         """
0077 
0078         return self.optional
0079 
0080     def getMandatoryRelease(self):
0081         """Return release in which this feature will become mandatory.
0082 
0083         This is a 5-tuple, of the same form as sys.version_info, or, if
0084         the feature was dropped, is None.
0085         """
0086 
0087         return self.mandatory
0088 
0089     def __repr__(self):
0090         return "_Feature" + repr((self.optional,
0091                                   self.mandatory,
0092                                   self.compiler_flag))
0093 
0094 nested_scopes = _Feature((2, 1, 0, "beta",  1),
0095                          (2, 2, 0, "alpha", 0),
0096                          CO_NESTED)
0097 
0098 generators = _Feature((2, 2, 0, "alpha", 1),
0099                       (2, 3, 0, "final", 0),
0100                       CO_GENERATOR_ALLOWED)
0101 
0102 division = _Feature((2, 2, 0, "alpha", 2),
0103                     (3, 0, 0, "alpha", 0),
0104                     CO_FUTURE_DIVISION)
0105 

Generated by PyXR 0.9.4
SourceForge.net Logo