Tutorialspoint

How will you explain Python Operator Overloading?

How will you explain  Python Operator Overloading?                               


1 Answer
Jayashree
, 15 Views

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.

Advertisements