Add method to a class from outside : Method : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Method »

 

Add method to a class from outside


class rec: pass                  

rec.name = 'Bob'                 
rec.age  = 40 


def upperName(self)
    return self.name.upper(  )   
rec.method = upperName 

x = rec(  )                      
y = rec(  ) 

x.method(  )
y.method(  )
rec.method(x)



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Class
» Method