
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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.
- Related Articles
- How can we do Python operator overloading with multiple operands?
- How will you explain Python namespaces in easy way?
- How to use Operator Overloading in C#?
- How to implement operator overloading in C#?
- How will you explain Python for-loop to list comprehension?
- Overloading unary operator in C++?
- Rules for operator overloading in C++
- Overloading array index operator [] in C++
- How will you explain that an exception is an object in Python?
- Increment ++ and Decrement -- Operator Overloading in C++
- Explain function of % operator in Python.
- What is overloading a unary operator in C++?
- Why is operator overloading not supported by java?
- C++ Program to Subtract Complex Number using Operator Overloading
- Explain difference between == and is operator in Python.

Advertisements