On 2008-11-11 18:09, Guido van Rossum wrote: > We're not going to add the "feature" back that None compares smaller > than everything. It's a slippery slope that ends with all operations > involving None returning None -- I've seen a proposal made in all > earnestness requesting that None+42 == None, None() == None, and so > on. This Nonesense was wisely rejected; a whole slew of > early-error-catching would have gone out of the window.
I was suggesting None of that. > It's the same > with making None smaller than everything else. For numbers, you can > already use -inf; for other types, you'll have to invent your own > Smallest if you need it. No, that doesn't work: -inf is a perfectly valid number, None isn't. Same for strings: '' would be a valid string that compares smaller than all others, None isn't. Furthermore, if you get a None value from some database or data set, you don't want to replace that special n/a value with a valid number or string - since you'd lose round-trip safety. In some cases you don't even know whether the item was supposed to be a number or e.g. a string, so there is no obvious choice for a replacement. Looks like data processing algorithms written for Python3 will have to start using key functions throughout or end up requiring lots of if-elif-elses to deal gracefully with the different combinations of comparison failures. Oh well, another surprise to add to the Python 3k list of surprises. And here's another one: >>> None < None Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: NoneType() < NoneType() >>> None is None True >>> None == None True >>> None > None Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: NoneType() > NoneType() >>> None != None False Two values that compare equal to each other (and are in fact identical), yet cannot be compared less-than or greater-than. This would make sense if you think of None as meaning "anything and/or nothing", since the left side None could stand for a different None than the right one, but then you could apply the same logic to inf: >>> inf = float('inf') >>> inf < inf False >>> inf is inf True >>> inf == inf True >>> inf > inf False >>> inf != inf False In this case you don't get any errors. Note all of this has to be seen from a user perspective, not from a CPython implementors perspective. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 11 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com