[Python-checkins] r60274 - python/trunk/Lib/rational.py
raymond.hettinger
python-checkins at python.org
Fri Jan 25 02:46:33 CET 2008
Author: raymond.hettinger
Date: Fri Jan 25 02:46:33 2008
New Revision: 60274
Modified:
python/trunk/Lib/rational.py
Log:
More design notes
Modified: python/trunk/Lib/rational.py
==============================================================================
--- python/trunk/Lib/rational.py (original)
+++ python/trunk/Lib/rational.py Fri Jan 25 02:46:33 2008
@@ -82,6 +82,10 @@
_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.
More information about the Python-checkins
mailing list