[Python-Dev] trunc()

Jeffrey Yasskin jyasskin at gmail.com
Sun Jan 27 09:19:39 CET 2008


On Jan 26, 2008 11:14 PM, Raymond Hettinger <python at rcn.com> wrote:
> The idea that programmers are confused by int(3.7)-->3 may not be nuts, but it doesn't match any experience I've had with any
> programmer, ever.

In C, I'm pretty sure I've seen people write (long)x where they'd have
been better off with lround(x). They know that the cast truncates, and
generally that they actually wanted to round, but the type they wanted
to get to was foremost in their mind, so they didn't bother to think
about it a little and write what they really wanted. It's not that
they're confused; it's that they're accepting a default that shouldn't
be a default.

Your other points seem to have been answered already, although people
will disagree on how compelling the answers are, so I won't repeat
them here.

-- 
Namasté,
Jeffrey Yasskin


More information about the Python-Dev mailing list