Thursday, April 23, 2009

Exercises 10.19, 20, 21

In Python 3.0 the __cmp__ special method was removed. In favor of keeping __lt__, __le__, __gt__, __ge__, __eq__, and __neq__. In the 'good old days' if you wrote __cmp__ that would suffice for any of the comparison operators. Now you must explicitly write a method for each comparison operator you want to write. If it seems weird and confusing you are right, in fact it took until Python 3.0.1 for the core python developers to truly rid the language of cmp.

You can implement any or all of these special methods for exercises 10.19, 10.20, and 10.21.

No comments:

Post a Comment