How will you explain Python Operator Overloading?


Every class in Python, whether built-in or user defined is inherited from object class. The object class has a number of properties whose name is preceded and followed by double underscores (__). Each of these properties is a wrapper around a method of same name. Such methods are called special or magic methods.

The magic methods __lt__(), __gt__(), __eq__(), __ne__(), etc. are overridden in a class to overload <, > == and != operators respectively.

Updated on: 30-Jul-2019

129 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements