Quelklef
Quelklef

Reputation: 2157

Python '//' integer division method in classes

How can I add an integer division // method to a class?

I can add a subtraction method like def __sub__(self, other):, so how can I do it with //?

I looked for this online, and couldn't find anything.

Using Python 3.

Upvotes: 2

Views: 744

Answers (1)

Warren Weckesser
Warren Weckesser

Reputation: 114946

You're looking for __floordiv__.

Upvotes: 4

Related Questions