(original) (raw)
On Fri, Apr 5, 2013 at 6:34 PM, Terry Jan Reedy <tjreedy@udel.edu> wrote:
2\. int(rational): for floats, Fractions, and Decimals, this returns the integral part, truncating toward 0\. Decimal and float have \_\_int\_\_ methods. Fractions, to my surprise, does not, so int must use \_\_floor\_\_ or \_\_round\_\_ as a backup.
It uses \_\_trunc\_\_, which is supposed to be the unambiguous "Yes I really want to throw away the fractional part and risk losing information" replacement for \_\_int\_\_. int() will try \_\_int\_\_ first, and then \_\_trunc\_\_, as per PEP 3141.
Mark