Is 0 > None??

Isaac To kkto at csis.hku.hk
Mon Sep 3 07:46:58 EDT 2001


>>>>> "Andy" == Andy Todd <andy_todd at spam.free.yahoo.com> writes:

    Andy> Thus to extrapolate from your posts above;

    >>>> if 0 > None:

    Andy> should make you say to yourself 'if zero is greater than I dont
    Andy> know', leading you to exactly the correct answer - false.

No (this ends up with 0 < None being false as well, but is clearly untrue).
Comparison of anything between unrelated types are bounded to end up in
arbitrary result.  The result is guaranteed to be consistent within a
specific run, or even a specific platform-version pair, but can differ if
platform or version changes.  None and Integer are of unrelated types, and
comparison should be done only to make things like an untyped hash.  This is
well documented, I think.

Regards,
Isaac.



More information about the Python-list mailing list