On Mon, Apr 21, 2014 at 8:52 AM, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote: > 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.
And that's what I mean about the common non-trivial case. It's easy enough to come up with contrived or trivial cases that use any types, but in most cases, it'd be fine to explicitly call float() on one of the operands to explicitly request floating-point division. Choosing between two division operators is not the same thing as choosing a data type. Explicitly choosing float division: x / float(y) Explicitly choosing to truncate: math.trunc(x / y) Both explicit forms can be done cleanly without empowering the language with the magic of int/int->float. ChrisA -- https://mail.python.org/mailman/listinfo/python-list