0

Why is the magic method __gt__ not necessary?

https://code.sololearn.com/cQgFCOXTbs86/?ref=app

11th Oct 2019, 8:18 PM
Mostapha Amenchar
Mostapha Amenchar - avatar
2 odpowiedzi
+ 2
lt gets called on the second instance: https://code.sololearn.com/cccdQwPhYe57/?ref=app Test it first without changing the code. Then it just calls gt on a1 but if you comment out gt it calls lt on a2!
11th Oct 2019, 8:47 PM
Thoq!
Thoq! - avatar
0
Because you can just ask for lower and equal, and if it's neither, it has to be greater.
11th Oct 2019, 8:43 PM
HonFu
HonFu - avatar