RE: Operator Overloading Basics

2006-08-28 Thread Mohit Bhatt
Thanks a lot Fredrik and Tim for your help. Cheers, Mohit -- http://mail.python.org/mailman/listinfo/python-list

Re: Operator Overloading Basics

2006-08-28 Thread Tim Chase
> obj1 = c1(1) > > obj1 + 10 # this works just fine > 10 + obj1 # throws exception > Q. What do I have to do to make the following line work? > > 10 + obj1 http://docs.python.org/ref/numeric-types.html You want to read the section on __radd__ (and it's o

Re: Operator Overloading Basics

2006-08-28 Thread Fredrik Lundh
Mohit Bhatt wrote: > Hello, > > I just started out with python( couple of weeks). > > I have a query regarding Operator Overloading > > class c1: > def __init__(self,value): > self.data = value > def __add__ (self,operand2): >