PEP0238 lament

Terry Reedy tjreedy at home.com
Mon Jul 23 00:52:26 EDT 2001


> Guys, if you really need something returning floats for division,
make it
> new operator, I guess everyone could be made happy with 1/2 == 0 and
1//2 ==
> 0.5.

I can sympathize with the people who have suggested this alternative,
but it strikes me as making things worse in a way.  The current
situation is this: '/' mixes  two types of division -- fractional
result and integer result.  This is fine with me, but I can understand
some having a problem.

Moshe's current proposal cleanly separates the two types: '/' will be
fractional result and '//' will be integer result (including
floor(float/float)).  So 8/3 = 8.0/3.0 = 2.33333, while 8//3 = 2 and
8.0//3.0 = 3.0, which is the same to within type, just as 3+8 ==
(withing type) 3.0+8.0.  (I am not sure about complex//complex since I
an not sure if floor(complex) is defined -- floor(x) + floor(y)*j?)
This is arguably what Python should have started with.

Adding '//' as a pure fractional division operator while '/' remains a
mixed division operator strikes me an unaesthetic and more confusing
than the current situation.  Why the two half redundant operators?
newcomers might rightly wonder.

Terry J. Reedy






More information about the Python-list mailing list