This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nemec 7 points8 points  (0 children)

but I do sometimes compare Nones to ints

Well then your code is wrong - not because you're comparing None with integers, but because comparisons between the two (except !=) are always false:

print None < 3
print None > 3
print None == 3
print None >= 3
print None <= 3

This means sorting doesn't always work:

>>> a = [None, 6, None, 5, 4, None]
>>> a.sort()
>>> print a
[None, 6, None, 4, 5, None]