PEP 303: Extend divmod() for Multiple Divisors

Erik Max Francis max at
Wed Jan 1 05:34:55 CET 2003

Thomas Bellman wrote:

> Abstract
>     This PEP describes an extension to the built-in divmod() function,
>     allowing it to take multiple divisors, chaining several calls to
>     divmod() into one.

Provided backward compatibility is strictly maintained, sounds fine with


> Rationale
>     The idea comes from APL, which has an operator that does this.  (I
>     don't remember what the operator looks like, and it would probably
>     be impossible to render in ASCII anyway.)

Oh boy oh boy!  I actually know this one.  It's an operator called
encode, which looks like a stylized T (you know, in the same way that
the "for every" symbol looks like a stylized inverted A).  (The decode
operator, which does the reverse operation, looks like an inverted T.) 
I don't know what the equivalent operator is in J, but no doubt there is

>     The APL operator takes a list as its second operand, ...

Actually, the APL operator takes the list of moduli as the left

I knew that reading that APL book (a language I am almost certain never
to use in the real world in my entire life) last month would pay off! 
Now I'll be rich and famous!

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ All your slick moves / They were once innocent moves
\__/ Sade Quake III Arena /
 A personal guide to Quake III Arena.

More information about the Python-list mailing list