[Samuele Pedroni] > one minor problem with the six __lt__ etc is that they should be > all defined. For quick things (although I know better) I still define > just __cmp__ out of laziness. Or out of sanity <wink>. 2.3's datetime type is interesting that way. The Python implementation of that (which lives in Zope3, and in a Python sandbox, and which you may want to use for Jython) now has lots of trivial variations of def __le__(self, other): if isinstance(other, date): return self.__cmp(other) <= 0 elif hasattr(other, "timetuple"): return NotImplemented else: _cmperror(self, other) Before 2.3a2, it just defined __cmp__ and so avoided this code near-duplication, but then we decided it would be better to let == and != return False and True (respectively, and instead of raising TypeError) when mixing a date or time or datetime with some other type.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4