Hi,

I'm trying to overload the divide operator in python for basic arithmetic.
eg. 10/2 ... no classes involved.

I am attempting to redefine operator.__div__ as follows:

     # my divide function
     def safediv(a,b):
         return ...

     # reassign buildin __div__
     import operator
     operator.__div__ = safediv

The operator.__dict__ seems to be updated OK but the '/' operator still  
calls buildin __div__

Does anyone know if this is possible and if I'm going along the correct  
path with my attempts above?
Is it possible to do this using a C extention?

Regards,
Shaun.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to