summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-25 01:46:33 +0000
committerRaymond Hettinger <python@rcn.com>2008-01-25 01:46:33 +0000
commit9ec7bc36fe9e16f8098c869e2bf48a16e08f9890 (patch)
tree8627f47803748b470f6205bbdcefd51a312ec454
parent9c6d81f5dd083ad536106bf723f705d70ddbe258 (diff)
downloadcpython-git-9ec7bc36fe9e16f8098c869e2bf48a16e08f9890.tar.gz
More design notes
-rwxr-xr-xLib/rational.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/rational.py b/Lib/rational.py
index d23f433969..e2083dba4a 100755
--- a/Lib/rational.py
+++ b/Lib/rational.py
@@ -82,6 +82,10 @@ def _binary_float_to_ratio(x):
_RATIONAL_FORMAT = re.compile(
r'^\s*(?P<sign>[-+]?)(?P<num>\d+)(?:/(?P<denom>\d+))?\s*$')
+# XXX Consider accepting decimal strings as input since they are exact.
+# Rational("2.01") --> s="2.01" ; Rational.from_decimal(Decimal(s)) --> Rational(201, 100)"
+# If you want to avoid going through the decimal module, just parse the string directly:
+# s.partition('.') --> ('2', '.', '01') --> Rational(int('2'+'01'), 10**len('01')) --> Rational(201, 100)
class Rational(RationalAbc):
"""This class implements rational numbers.