In article 
<aanlktim1wmz-ujxuk4no6b85hiidyqhanu6acyccd...@mail.gmail.com>,
 wheres pythonmonks <wherespythonmo...@gmail.com> wrote:
> I did the google search... I must be blind as I don't see any hits...
> 
> None is negative in Python?  (v2.6)
> 
> http://www.google.com/search?ie=UTF-8&q=%22none+is+negative%22+python
> 
> >>> if None < -9999999.99: print "hi"
> 
> hi
> >>>
> 
> >>> if -9999999 > None: print "hi"
> 
> hi
> >>>
> 
> Is there a way to have the comparison raise an exception?

This is a well-known wart in Python 2.  The behavior has been changed in 
Python 3.

$ python
Python 2.6.5 (r265:79063, Jul 15 2010, 01:53:46) 
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> None < -9.9
True
>>> 
$ python3
Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> None < -9.9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() < float()
>>>

-- 
 Ned Deily,
 n...@acm.org

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to