On Tue, Nov 11, 2008 at 7:06 AM, M.-A. Lemburg <span dir="ltr"><<a href="mailto:mal@egenix.com">mal@egenix.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Why was the special case for None being "smaller" than all other<br>
objects in Python removed from Python 3.0 ? (see object.c in Py2.x)<br>
</blockquote><div><br>It wasn't true in Python 2.5, either. Observe:<br><br>Cashew:~/pokersleuth/tracker$ python2.5<br>Python 2.5 (r25:51908, Feb 26 2007, 08:19:26)<br>[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin<br>
Type "help", "copyright", "credits" or "license" for more information.<br>>>> import datetime<br>>>> now = datetime.datetime.now()<br>>>> now < None<br>
Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>TypeError: can't compare datetime.datetime to NoneType<br><br><br>Right now to get the desired semantics, I implement a custom AlwaysLeast and/or AlwaysGreatest singletons for whatever type I'm dealing with. It's a bit of of a pain. My use cases are all along the following lines:<br>
</div></div><br>class TimeSpan:<br> def __init__(self):<br> self.earliest = AlwaysGreatest<br> self.latest = AlwaysLeast<br><br> def update(self, v):<br> self.earliest = min(self.earliest, v)<br>
self.latest = max(self.latest, v)<br><blockquote style="margin: 1.5em 0pt;">--<br>
Daniel Stutzbach, Ph.D.<br>
<a href="http://www.barsoom.org/%7Eagthorr">http://www.barsoom.org/~agthorr</a></blockquote>