Comment on PEP-0238

Guido van Rossum guido at python.org
Sun Jul 8 08:11:23 EDT 2001


> [Tim Peters]
> 
> > I want to make a pitch for naming it idiv() instead.  The "i" should
> > strongly remind that the result is an integer, something "div" says only to
> > former Pascal programmers.

pinard at iro.umontreal.ca (François Pinard) writes:

> idiv suggests FORTRAN to me! :-) I prefer being remembered of
> Pascal! :-) :-)
> 
> And I like the idea of div(), mod() and divmod(): it's clean.

Yeah, I don't see the point of idiv either.  Plus, __idiv__ is already
in use to mean in-place division (i.e. the /= operator).

I just discovered that we don't need to add a new operator overloading
name for the div and mod operations: classes already look for a
__divmod__ method to overload divmod(), and we should naturally define
div(x, y) (or x div y) as divmod(x, y)[0].  Ditto for mod if it gets
added.

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



More information about the Python-list mailing list