[Tutor] Overriding equality tests in Python
John Steedman
johnsteedman360 at gmail.com
Sat Mar 23 10:10:50 CET 2013
It is also good to know that overriding the "comparison magic methods" in
your class can be very useful if you wish to apply sorting/searching
procedures available in python.
If you also implement __gt__, __lt__, __ge__, __le__ in your class, then
you can append each of your objects to a list and successfully use the
sorted () function on that list. It will enable you to have your list
sorted by some other variables within your class, such as the number
scored.
John S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130323/4513aa37/attachment.html>
More information about the Tutor
mailing list