Using fractions instead of floats

Terry Reedy tjreedy at udel.edu
Mon Oct 1 23:33:45 EDT 2007


"andresj" <andres.j.new at gmail.com> wrote in message 
news:1191283765.496514.94080 at 50g2000hsm.googlegroups.com...
|| I know from __future__ import division changes the behaivour to return
| floats instead of ints, but what I meant is to be able to implement a
| function (or class/method) which would return what _I_ want/decide.

When you define your own class, you can make any operator (on instances of 
that class) mean anything you want.  But to use such methonds, once 
defined, you first have to make instances of that class using 
classname(init data) or whatever.

There is no way to hijack int op int though.

tjr






More information about the Python-list mailing list