[Python-Dev] Semantics of int(), index() (original) (raw)

Mark Dickinson dickinsm at gmail.com
Sat Apr 6 22:34:19 CEST 2013


On Fri, Apr 5, 2013 at 6:34 PM, Terry Jan Reedy <tjreedy at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130406/8e0cbb49/attachment.html>



More information about the Python-Dev mailing list