Base Overloading Methods in Python

PythonServer Side ProgrammingProgramming

Following table lists some generic functionality that you can override in your own classes −

Sr.No.Method, Description & Sample Call
1__init__ ( self [,args...] )
Constructor (with any optional arguments)
Sample Call : obj = className(args)
2__del__( self )
Destructor, deletes an object
Sample Call : del obj
3__repr__( self )
Evaluable string representation
Sample Call : repr(obj)
4__str__( self )
Printable string representation
Sample Call : str(obj)
5__cmp__ ( self, x )
Object comparison
Sample Call : cmp(obj, x)
raja
Published on 30-Jan-2020 07:20:16
Advertisements