[Python-Dev] trunc()

Jeffrey Yasskin jyasskin at gmail.com
Fri Jan 25 19:03:38 CET 2008


On Jan 25, 2008 9:45 AM, Facundo Batista <facundobatista at gmail.com> wrote:
> 2008/1/25, Jeffrey Yasskin <jyasskin at gmail.com>:
>
> > decision comes to be that int(float) should be blessed as a correct
> > way to truncate a float, I'd agree with Raymond that trunc() is just
> > duplication and should be eliminated. I'd, of course, rather have a
> > spelling that says what it means. :)
>
> Mmm... no. int() is a builtin way to transform the builtin data type
> float into the builtin data type float.

I assume you meant "int" instead of your second "float".

There doesn't have to be a way to convert from every builtin type to
every other builtin type. Take dict(float), for example. Further, if
there is a conversion, no law says it has to be named the same as the
target type. If there are two plausible ways to get from the source to
the target, using just the target's name to pick out one of them is
really a terrible idea.

But, just because the designers of C made a bad decision that we've
inherited, doesn't mean that it's a terrible idea to keep it. As Nick
said, defining int(float) as truncation has a long history, and there
are some obvious costs to breaking away from that. I think it is time
to correct the mistake, but it's not an open and shut case.

--
Namasté,
Jeffrey Yasskin


More information about the Python-Dev mailing list