[Python-checkins] CVS: python/dist/src/Lib __future__.py,1.2,1.3

Tim Peters tim_one@users.sourceforge.net
Thu, 01 Mar 2001 18:53:10 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv17770/python/dist/src/Lib

Modified Files:
	__future__.py 
Log Message:
Make names in __future__.py bind to class instances instead of 2-tuples.
Suggested on c.l.py by William Tanksley, and I like it.


Index: __future__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/__future__.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** __future__.py	2001/02/28 08:26:44	1.2
--- __future__.py	2001/03/02 02:53:08	1.3
***************
*** 3,12 ****
  Each line is of the form:
  
!     FeatureName = ReleaseInfo
  
- ReleaseInfo is a pair of the form:
- 
-     (OptionalRelease, MandatoryRelease)
- 
  where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
  of the same form as sys.version_info:
--- 3,8 ----
  Each line is of the form:
  
!     FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease) ")"
  
  where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
  of the same form as sys.version_info:
***************
*** 38,44 ****
  MandatoryRelease may also be None, meaning that a planned feature got
  dropped.
  
! No line is ever to be deleted from this file.
  """
  
! nested_scopes = (2, 1, 0, "beta", 1), (2, 2, 0, "final", 0)
--- 34,69 ----
  MandatoryRelease may also be None, meaning that a planned feature got
  dropped.
+ 
+ Instances of class _Feature have two corresponding methods,
+ .getOptionalRelease() and .getMandatoryRelease().
  
! No feature line is ever to be deleted from this file.
  """
+ 
+ class _Feature:
+     def __init__(self, optionalRelease, mandatoryRelease):
+         self.optional = optionalRelease
+         self.mandatory = mandatoryRelease
+ 
+     def getOptionalRelease(self):
+         """Return first release in which this feature was recognized.
+ 
+         This is a 5-tuple, of the same form as sys.version_info.
+         """
+ 
+         return self.optional
+ 
+     def getMandatoryRelease(self):
+         """Return release in which this feature will become mandatory.
+ 
+         This is a 5-tuple, of the same form as sys.version_info, or, if
+         the feature was dropped, is None.
+         """
+ 
+         return self.mandatory
+ 
+     def __repr__(self):
+         return "Feature(" + `self.getOptionalRelease()` + ", " + \
+                             `self.getMandatoryRelease()` + ")"
  
! nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "final", 0))