operator over loading

Anand K Rayudu anand at easi.soft.net
Fri May 21 03:05:34 EDT 2004


Hi all,

I have defined q python class and want to know if i can over load '=' 
operator.

Here is my scenario

Def myClass:
   __init__(self,a):  # a is C Object
      c_obj = a

   __del__
      delete c object.

b = myClass(c_obj1)
c = myClass(c_obj2)

#python expression
a=tan(sin(b)*cos(c))

Where sin, cos & tan and '*' are over loaded, and the result of this is 
assigned to variable a.

Now the problem is cos(c), sin(b) creates new objects, which are used 
for multiplication.
This again generates a new object,
What i want to do it automatically delete all intermediate objects. 
except the one assigned to a.
currently i am deleteing c object in __del__
So once I reassing some thing else to a that is also getting deleted.
So what i want to do is once i assign it to a variable, i want to set 
flag so that i won;t delete it in _del_

Can some some suggest is there any better way of doing the same,
Thanks & Best Regards.
Anand






More information about the Python-list mailing list