Serhiy Storchaka <> added the comment:

Wouldn't be better to add the function as_integer_ration() in the math module 
(or in more appropriate place)?

def as_integer_ration(x):
    if hasattr(x, 'as_integer_ration'):
        return x.as_integer_ration()
        return (x.numerator, x.denominator)

The advantage over adding the int method is that it will automatically support 
other rational numbers like NumPy integers.

nosy: +serhiy.storchaka

Python tracker <>
Python-bugs-list mailing list

Reply via email to