I am sad that such code (as well as my former code in total_ordering) no longer works, but this is just a clever trick, and the code can be written in less clever but more explicit way.
On other hand, the warning helps to catch common mistakes like
not self.__lt__(other)
self.__lt__(other) or self.__eq__(other)
super().__eq__(other) and self.x == other.x
Even non-beginners often make such kind of mistakes, and it is hard to catch them if you have not trained yourself specially. I suggest you to include lessons about writing complex comparison methods in your course for advanced users. |