[Python-Dev] trunc()

Paul Moore p.f.moore at gmail.com
Fri Jan 25 21:32:53 CET 2008


On 25/01/2008, Guido van Rossum <guido at python.org> wrote:
> Does no-one thinks it means round(f) either? That's the main confusion
> here (plus the fact that in C it's undefined -- or at some point was
> undefined).

Not me. My intuition agrees with Raymond that int means "the integer
part of", i.e. trunc(), when dealing with a numeric argument.
(int(string) is a different matter, and I have no problem having
different intuitions for that. So sue me)

I'd like to keep trunc (as math.trunc) for those cases where I want to
be completely explicit, but it's not a big deal to me.

> BTW the list of functions considered here should include round() in
> addition to ceil(), floor(), and trunc(), even if 2-arg round()
> doesn't quite fit.

My original message suggested that round go into math as well. It
didn't get much comment, though, as everyone latched onto the more
controversial suggestion that int(float) be an error - which is the
bit I was least concerned about, ironically.

Paul.


More information about the Python-Dev mailing list