Base Overloading Methods in Python


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)

Updated on: 30-Jan-2020

336 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements