Re: __div__ not recognized automatically

2006-11-09 Thread Peter Otten
Anton81 wrote: >> If you have the >> >> from __future__ import division >> >> statement, you need to override __truediv__(), not __div__() > > That worked after I also added > from __future__ import division > to all other modules I created. > > Is it possible that there appears an inconsisten

Re: __div__ not recognized automatically

2006-11-07 Thread Anton81
> If you have the > > from __future__ import division > > statement, you need to override __truediv__(), not __div__() That worked after I also added from __future__ import division to all other modules I created. Is it possible that there appears an inconsistency if the division is imported in

Re: __div__ not recognized automatically

2006-11-02 Thread Tuomas
Try a=(b+c)/NumX(2) TV Anton81 wrote: > Hello! > > I wrote a class > > class NumX: > ... > def __add__(self,other): > ... > def __div__(self,other): > if not isinstance(other,NumX): other=NumX(other) > ... > > Somewhere else I use > > a=(b+c)/2 > > where all variables are

Re: __div__ not recognized automatically

2006-11-02 Thread Peter Otten
Anton81 wrote: > Hello! > > I wrote a class > > class NumX: > ... > def __add__(self,other): > ... > def __div__(self,other): > if not isinstance(other,NumX): other=NumX(other) > ... > > Somewhere else I use > > a=(b+c)/2 > > where all variables are of NumX Type. When I exec

Re: __div__ not recognized automatically

2006-11-02 Thread Nick Craig-Wood
Anton81 <[EMAIL PROTECTED]> wrote: > class NumX: >... >def __add__(self,other): > ... >def __div__(self,other): > if not isinstance(other,NumX): other=NumX(other) > ... > > Somewhere else I use > > a=(b+c)/2 > > where all variables are of NumX Type. When I execute

Re: __div__ not recognized automatically

2006-11-02 Thread Steven D'Aprano
On Thu, 02 Nov 2006 12:59:32 +0100, Anton81 wrote: > When I execute the program it > complains that it can't find an operator "/" for "instance" and "integer". How about if you post the actual traceback you get, rather than paraphrasing? That way, we don't have to guess. -- Steven. -- http:/

__div__ not recognized automatically

2006-11-02 Thread Anton81
Hello! I wrote a class class NumX: ... def __add__(self,other): ... def __div__(self,other): if not isinstance(other,NumX): other=NumX(other) ... Somewhere else I use a=(b+c)/2 where all variables are of NumX Type. When I execute the program it complains that it can't find an