[Patches] import floatdivision # 1/2==0.5

M.-A. Lemburg mal@lemburg.com
Tue, 13 Jun 2000 10:19:54 +0200


Moshe Zadka wrote:
> 
> On Mon, 12 Jun 2000, David Scherer wrote:
> 
> > This patch provides a way to make 1/2==0.5 optional without introducing any
> > backward incompatibilities.  It provides a pseudomodule "floatdivision"
> > that, when imported, changes the behavior of the importing script at compile
> > time:
> >
> > import floatdivision
> > print 3/4             # 0.75
> 
> -1 on that. I don't like language to be dependant on modules: no "library"
> can import this module, because it might break other code. On the other
> hand, no "application" can import this module, because it might break
> library code. Plus a general -1 on thrusting floating point in innocent
> people's faces.

-1 from here too for much the same reasons. 

While introducing some kind of float division is probably a good
idea for CP4E, I wouldn't like to have to scan 100k LOCs just to
figure out which of them rely on 5/2 returning 2 instead of 2.5. Some
time ago there was a discussion about introducing 5//2 to
give 2.5 (or was it the other way around ?).

Note that writing 3/4. will solve the problem without any
new language features. For variable arguments you can write
a/float(b) which is pretty nice to read too.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/