[Tutor] Division

Tim Peters tim.one@home.com
Sun, 2 Dec 2001 14:10:16 -0500


[Gregor Lingl]
> As I'm starting to give a new course 'Introduction to
> programming' in Jan 2002. It's for young students in the
> age of 15/16. (Of course) I shall use Python.
> I'd consider it an advantage not to confuse my students
> in the beginning with the specialities the overlaoding of 
> the division-operator (although I had to do so for several times
> until now). But neither with the import from future
> statement.
>
> So my question is: Is there a way to start the Python-Interpreter
> with new division enabled, so one needs not to write 
> 'from __future__ import division' at the beginning of every program
> file which uses division (using some switch, editing some startup 
> file or similar)?

Skip down to the "Command Line Option" section of PEP 238:

    http://python.sf.net/peps/pep-0238.html

As it says,

    The "new" option is only intended for use in certain educational
    environments, where true division is required, but asking the
    students to include the future division statement in all their
    code would be a problem.

C:\Code\python\PCbuild>python -Qnew
Python 2.2b2+ (#26, Nov 28 2001, 19:17:11) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>> 1//2
0
>>>