[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues

Guido van Rossum guido@python.org
Wed, 09 Oct 2002 12:13:09 -0400


> Tim Peters <tim.one@comcast.net> writes:
> > 2/3r works for both for me.  0.666...7 doesn't work for me at all as
> > a stringification of a rational (if I want to approximate, I'll ask
> > for an approximation).
> 
> I agree.  I initially thought about returning a decimal with str(),
> but for that reason chose not to.  It might be nice to have a method
> that returned the best floating point decimal approximation to within
> n decimal digits or shorter, but I don't want a builtin to make an
> arbitrary decision on where to cut off precision.
> 
> I do like the idea of str() returning the form 5+3/2r, though.

Well, that would completely kills any possibility of ever making 1/3
return a rational (currently the main argument against it is the
expectation amongst the current user base that it will be a float).

I really don't think that this would be reasonable at all:

  Python 3.0 (#2345, Mar 12 2005, 11:32:10)
  Type "help", "copyright", "credits" or "license" for more information.
  >>> print 25/7
  25/7
  >>>

--Guido van Rossum (home page: http://www.python.org/~guido/)