Operator symbol for "nb_intdivide"

Peter Hansen peter at engcorp.com
Thu Jul 26 21:02:51 EDT 2001


Rainer Deyke wrote:

> My vote (if I had one): keep '/' for integer division and introduce a new
> symbol for floating point division.
> 
> Justification:
> 
>   - Everybody uses integers, but not everybody uses floats.  Therefore, if
> '/' is used for integers, then fewer people will have to change their code.

This suggests you pretty much missed the past ten thousand posts in
this newsgroup! :-)  The whole point of the change is roughly that many 
people who _do_ use integers, without knowing much about this whole issue, 
are more likely to expect "true" division rather than the classic behaviour.

Yes, there will be code breakage.  The decision appears largely to be
between _inevitable_ code breakage for a short period and _invisible_
bugs for eternity (that being how long we expect Python to be used :-).

>   - The short and pretty modulus operator should be matched with a short and
> pretty integer division operator.

// is growing on me.  I can survive without div and mod, I think.
I would have agreed with you a few days ago, but my aesthetic
sense is adapting rapidly here, as inevitability proclaims itself...

>   - It makes floats more difficult for newbies.  This is a good thing, since
> floats are dangerous.

Floats are probably not that dangerous for newbies.  Newbies
(in the sense I use the word) tend to write toy applications,
or not use floats at all (as in "everybody uses integers").
I think one could argue persuasively that this change, proposed
perhaps somewhat with newbies in mind, *reduces* the danger
to them.

But I don't think it's really newbies in the usual sense who
are the trigger for this change.  It appears to be more the casual
users, who might not be programmers per se (newbie or otherwise), 
but people in other fields (say, a lab technician, or a chemistry 
student) who would attempt to use Python for some simple mathematical 
work and get mysterious (or unnoticed!) totally inaccurate results 
when they enter some data as an integer and try to divide the 
"expected" way, and get data loss as a result.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list