PEP 303: Extend divmod() for Multiple Divisors

John Roth johnroth at
Wed Jan 1 13:45:03 CET 2003

"Thomas Bellman" <bellman+pep-divmod at> wrote in message
news:ausiq8$egi$1 at
> This PEP proposes extending divmod() to accept multiple divisors.
> Please give your comments.  It can also be read on the web at
> <URL:>.

I want to object to this one strongly, on the basis that it is
a special case of something that, if it's useful at all, should
be generalized to include all of the operators.

Erik Mac Francis' comment about the APL encode operator
sounds about right, although I'd much prefer that thinking
go in the direction of functional languages.

I don't find the use cases very compelling. Sure, they exist,
but how many of us actually use chained division for those
conversions in every day life rather than use a library
module? And how many of those uses are actually
the performance bottleneck in the system?

As far as the nuts and bolts go, the operand should be
a sequence, not simply strung out as operands. There are
several reasons for this, but the major one is consistency:
if the result is a list, then the input operand should also be
a list.

John Roth

More information about the Python-list mailing list