[issue1682] Move Demo/classes/Rat.py to Lib/rational.py and fix it up.

Mark Dickinson report at bugs.python.org
Sat Jan 19 02:59:35 CET 2008


Mark Dickinson added the comment:

(About the latest patch):  this all looks good to me.

The comment that "Decimal provides no other public way to detect nan and infinity." is not 
true (though it once was).  Decimal has public methods is_nan and is_infinite, added as 
part of updating to the most recent specification.  (Yes, it also has private methods 
_isnan and _isinfinity, dating from long ago;  I'm working on a patch that gets rid of the 
duplication.)

(About the approximation methods):  I agree that these aren't a necessary part of a 
Rational module---just something that might be nice to have around.  So my vote would be 
for adding either 0 or 1 of these;  adding two such similar methods with similar use-cases 
just seems like a cause of possible confusion to me.  I'd also vote against a method for 
providing the convergents of the continued-fraction, but that's just me.  See what python-
dev says!

One interesting use-case for approximate is to recover a simple rational from a float, in 
a case where the float was rational to begin with, but lost a little accuracy in 
conversion;  approximate works well here because you generally have some idea how close 
the float is to the rational.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1682>
__________________________________


More information about the Python-bugs-list mailing list