On Apr 18, 5:19 pm, Steven Howe <[EMAIL PROTECTED]> wrote: > 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
None is a singleton - there is but one None and no other. The only comparisons that make sense with None are "is" or "is not". type(x) == NoneType is unnecessary, x is None is sufficient. >>> x = None >>> x is None True >>> y = None >>> x is y True >>> z = object() >>> z is None False >>> z is not None True >>> x is not None False >>> y is not None False -- Paul -- http://mail.python.org/mailman/listinfo/python-list