dgrisby at uk.research.att.com
Tue Jul 24 09:27:47 EDT 2001
In article <mailman.995977483.25907.python-list at python.org>,
Paul Prescod <paulp at ActiveState.com> 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(). (or maybe I've missed something there)
As long as the definition of divmod() is updated to do that. It
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() can be used, but it isn't exactly concise or
easy to follow.
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list