PEP0238 lament

Duncan Grisby dgrisby at
Tue Jul 24 09:27:47 EDT 2001

In article <mailman.995977483.25907.python-list at>,
 Paul Prescod  <paulp at> wrote:

>> I return to my question. Suppose Python 2.2 is released with this
>> __future__ division. Now suppose I must maintain some code which can
>> run on Python 2.0, 2.1 and 2.2, which needs integer division. What am
>> I to do? 
>I think divmod()[0]. (or maybe I've missed something there)

As long as the definition of divmod() is updated to do that. It
currently says

  divmod(a, b) 
       Take two numbers as arguments and return a pair of numbers
       consisting of their quotient and remainder when using long
       division. With mixed operand types, the rules for binary
       arithmetic operators apply. For plain and long integers, the
       result is the same as (a / b, a % b). ...

Assuming divmod() continues to returns integers with integer
arguments, divmod()[0] can be used, but it isn't exactly concise or
easy to follow.



 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- --

More information about the Python-list mailing list