Why Python 3?

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Apr 20 18:52:11 EDT 2014


Chris Angelico wrote:
> Truncating vs true is not the same as int vs float. If you mean to
> explicitly request float division, you call float() on one or both
> arguments. You're being explicit about something different.

If you know you're dealing with either ints or floats,
which is true in the vast majority of cases, then you
know that / will always perform float division.
As for why int/int should yield float and not some
other type, float is alreay special -- it's built-in
and has syntactic support in the form of literals.
It's the most obvious choice.
If a version of Python were ever to exist in which
floating-point literals produced Decimals instead of
floats, then int/int would produce a Decimal.
-- 
Greg


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /