comparison with None

Steven Howe howe.steven at gmail.com
Wed Apr 18 18:19:26 EDT 2007


Alan G Isaac wrote:
>  >>> None >= 0
> False
>  >>> None <= 0
> True
>
> Explanation appreciated.
>
> Thanks,
> Alan Isaac
>   
I've read and found that 'None' comparisons is not always a good idea.
Better to:
from types import NoneType

x = None
if type( x ) == NoneType:
    # true
    < code >
else:
    # false; do something else.
    < more code >

Steven Howe




More information about the Python-list mailing list