None is negative?

Benjamin Kaplan benjamin.kaplan at case.edu
Tue Aug 3 16:24:22 EDT 2010


On Tue, Aug 3, 2010 at 1:17 PM, wheres pythonmonks
<wherespythonmonks at 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?
>
> W


Use Python 3. One of the (backwards-incompatible) changes was to have
comparisons of incompatible types raise exceptions. The behavior in
Python 2 (not just with None, but with other built-in types as well)
was to return an arbitrary but consistent result.



More information about the Python-list mailing list