Re: [Python-Dev] functions vs methods (was Re: trunc())

Please ignore my last email. The idea for combining trunc, ceil, floor, etc was probably just a distractor. [GvR]
One thing I'm beginning to feel more and more strongly about is that round, trunc, ceil and floor all belong in the same category, and either should all be builtins or should all be in math.
+1 for all four going into the math module.
I should also admit that the 2-arg version of round() was borrowed from ABC, but the use case for it there doesn't map to Python: in ABC it's the only tool you have for floating point formatting on output, while in Python the same thing would typically be done with "%.2f" % x rather than round(x, 2).
+1 for deprecating the second argument to round(). Raymond

Raymond Hettinger wrote:
Please ignore my last email. The idea for combining trunc, ceil, floor, etc was probably just a distractor.
I was going to suggest the same round(n, mode="round_method_of choice") to both round and int(), where int is more forgiving for input. But wasn't convinced.
[GvR]
One thing I'm beginning to feel more and more strongly about is that round, trunc, ceil and floor all belong in the same category, and either should all be builtins or should all be in math.
+1 for all four going into the math module.
Works for me. It seems simple enough to just do ... from math import round_even as round This gives me the specific rounding behavior I want without a lot of noise. Ron
I should also admit that the 2-arg version of round() was borrowed from ABC, but the use case for it there doesn't map to Python: in ABC it's the only tool you have for floating point formatting on output, while in Python the same thing would typically be done with "%.2f" % x rather than round(x, 2).
+1 for deprecating the second argument to round().
Raymond _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/rrr%40ronadam.com
participants (2)
-
Raymond Hettinger
-
Ron Adam