[Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

M.-A. Lemburg mal at egenix.com
Tue Aug 1 11:37:50 CEST 2006

Greg Ewing wrote:
> Raymond Hettinger wrote:
>> I think this would harm more than it would help.  It more confusing to 
>> have several rounding-thingies to choose from than it is have an 
>> explicit two-step.
> But is it more confusing enough to be worth forcing
> everyone to pay two function calls instead of one
> in the most common case?

I suppose you don't know about the optional argument
to round that lets you round up to a certain decimal ?!

If we were to follow your suggestion, we'd have round()
return an integer when called without the argument and
a float when called with the argument.

Dependency of the return type on arguments to a function
should be avoided, if possible.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Aug 01 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Python-Dev mailing list