int.numerator
and int.denominator
are a mystery to me.
help(int.numerator)
states:
the numerator of a rational number in lowest terms
But as far as I know, int
is not a rational number. So why do these properties exist?
int.numerator
and int.denominator
are a mystery to me.
help(int.numerator)
states:
the numerator of a rational number in lowest terms
But as far as I know, int
is not a rational number. So why do these properties exist?
See http://docs.python.org/library/numbers.html - int (
numbers.Integral
) is a subtype ofnumbers.Rational
.The denominator of an int is always
1
while its numerator is the value itself.In PEP 3141 you find details about the implementation of the various number types, e.g. proving the previous statement: