Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Special functions for some common operators#

Sumit Rawal answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Special functions for some common operators#

0

Below are some common special functions that can be overloaded while implementing operators for objects of a class.

Operator Method

+ __add__ (self, other)

- __sub__ (self, other)

/ __truediv__ (self, other)

* __mul__ (self, other)

< __lt__ (self, other)

> __gt__ (self, other)

== __eq__ (self, other)

It is for the user to decide how they want the objects to interact when an operator operates on them, but they usually need to make sure that these operations make sense. For example, the + is not going to be used for finding products of different properties of a class.

Popularity 1/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: whatever
Link to this answer
Share Copy Link
Contributed on May 17 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.