[Tutor] from __future__ import division

Alan Gauld alan.gauld at btinternet.com
Mon Mar 24 01:25:36 CET 2008

"Steve Willoughby" <steve at alchemy.com> wrote

> normal division x/y works just as expected, with one caveat: 
> remember
> that if you divide two *integer* values, you will get an *integer*
> division operation yielding an *integer* result.  So:

It's worth pointing out that although beginners tend to find this
behaviour odd it is actually very useful for many types of
programming problem(*). That's why the future mechanism includes
a new operator to do the older style integer division

(*)Some examples include manipulating indices into lists,
selecting from limited ranges, dealing with cyclic lists etc.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list