Operator Overloading : Operator Overloading : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Operator Overloading »

 

Operator Overloading


class Number:
    def __init__(self, start):                
        self.data = start
    def __sub__(self, other):                 
        return Number(self.data - other)      

X = Number(5)                             
Y = X - 2                                 
print Y.data



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Operator Overloading