[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues
Guido van Rossum
guido@python.org
Tue, 08 Oct 2002 12:09:57 -0400
> So we could have:
>
> >>> repr(r)
> '3/5r' # or 'rat(3, 6)'
Surely you meant 'rat(3, 5)'. :-)
> >>> str(r)
> '3/5'
I'd like at least one of those return '0.6' or '0.6r'. I think str(r)
should return '0.6', and then repr(r) could return '3/5r'. For values
that require approximation as decimal, I'd say use the same number of
digits that str() of a float currently uses (about 12 I believe). So
str(1/3r) should be '0.333333333333'.
--Guido van Rossum (home page: http://www.python.org/~guido/)