home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_Lib___future__.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  2.1 KB  |  70 lines

  1. """Record of phased-in incompatible language changes.
  2.  
  3. Each line is of the form:
  4.  
  5.     FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ")"
  6.  
  7. where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
  8. of the same form as sys.version_info:
  9.  
  10.     (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
  11.      PY_MINOR_VERSION, # the 1; an int
  12.      PY_MICRO_VERSION, # the 0; an int
  13.      PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
  14.      PY_RELEASE_SERIAL # the 3; an int
  15.     )
  16.  
  17. OptionalRelease records the first release in which
  18.  
  19.     from __future__ import FeatureName
  20.  
  21. was accepted.
  22.  
  23. In the case of MandatoryReleases that have not yet occurred,
  24. MandatoryRelease predicts the release in which the feature will become part
  25. of the language.
  26.  
  27. Else MandatoryRelease records when the feature became part of the language;
  28. in releases at or after that, modules no longer need
  29.  
  30.     from __future__ import FeatureName
  31.  
  32. to use the feature in question, but may continue to use such imports.
  33.  
  34. MandatoryRelease may also be None, meaning that a planned feature got
  35. dropped.
  36.  
  37. Instances of class _Feature have two corresponding methods,
  38. .getOptionalRelease() and .getMandatoryRelease().
  39.  
  40. No feature line is ever to be deleted from this file.
  41. """
  42.  
  43. class _Feature:
  44.     def __init__(self, optionalRelease, mandatoryRelease):
  45.         self.optional = optionalRelease
  46.         self.mandatory = mandatoryRelease
  47.  
  48.     def getOptionalRelease(self):
  49.         """Return first release in which this feature was recognized.
  50.  
  51.         This is a 5-tuple, of the same form as sys.version_info.
  52.         """
  53.  
  54.         return self.optional
  55.  
  56.     def getMandatoryRelease(self):
  57.         """Return release in which this feature will become mandatory.
  58.  
  59.         This is a 5-tuple, of the same form as sys.version_info, or, if
  60.         the feature was dropped, is None.
  61.         """
  62.  
  63.         return self.mandatory
  64.  
  65.     def __repr__(self):
  66.         return "Feature(" + `self.getOptionalRelease()` + ", " + \
  67.                             `self.getMandatoryRelease()` + ")"
  68.  
  69. nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "final", 0))
  70.