Comment on PEP-0238

Peter Hansen peter at engcorp.com
Sat Jul 7 10:14:52 EDT 2001


Terry Reedy wrote:
> 
> GvR:
> > I currently favor div(x, y) over x//y and x div y.  Maybe also add
> > mod(x, y) for symmetry (that would also explain divmod() as a
> > messenger from the future :-).
> 
> I suspect that some newbies and
> CP4E people would find *that* (div()) strange.

I suspect that newbiews and CP4E people rarely need the integer
division behaviour and wouldn't care or even realize about div().

In my mind integer division is usually related to operations
I think about in terms of the processor (maybe by picturing
the assembly code or something).  From this point of view,
div() is actually probably more reasonable than // or x div y.

I think // could actually be the worst as from a readability
point of view it looks too much like just / and could lead
to tricky bugs.

If div() is used, then mod() and divmod() should also both
be present, again thinking from the point of view of the 
way processors work and the assembly code (producing the 
remainder in other registers simultaneously with the 
quotient).

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



More information about the Python-list mailing list