summaryrefslogtreecommitdiffstats
path: root/Lib/__future__.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-03-02 02:53:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-03-02 02:53:08 (GMT)
commitd74bc432b2964599d8261aa367c9591080d623d3 (patch)
tree67f10c9691194977e896ce724916007074098b1f /Lib/__future__.py
parent239432a54515e230e19d92b9e1be0a071d8b826c (diff)
downloadcpython-d74bc432b2964599d8261aa367c9591080d623d3.zip
cpython-d74bc432b2964599d8261aa367c9591080d623d3.tar.gz
cpython-d74bc432b2964599d8261aa367c9591080d623d3.tar.bz2
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.
Diffstat (limited to 'Lib/__future__.py')
-rw-r--r--Lib/__future__.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/Lib/__future__.py b/Lib/__future__.py
index 2c263b7..3008f22 100644
--- a/Lib/__future__.py
+++ b/Lib/__future__.py
@@ -2,11 +2,7 @@
Each line is of the form:
- FeatureName = ReleaseInfo
-
-ReleaseInfo is a pair of the form:
-
- (OptionalRelease, MandatoryRelease)
+ FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease) ")"
where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
of the same form as sys.version_info:
@@ -38,7 +34,36 @@ to use the feature in question, but may continue to use such imports.
MandatoryRelease may also be None, meaning that a planned feature got
dropped.
-No line is ever to be deleted from this file.
+Instances of class _Feature have two corresponding methods,
+.getOptionalRelease() and .getMandatoryRelease().
+
+No feature line is ever to be deleted from this file.
"""
-nested_scopes = (2, 1, 0, "beta", 1), (2, 2, 0, "final", 0)
+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))