home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / c / comparison < prev    next >
Text File  |  1996-11-14  |  2KB  |  46 lines

  1. <TITLE>Comparisons -- Python library reference</TITLE>
  2. Next: <A HREF="../n/numeric_types" TYPE="Next">Numeric Types</A>  
  3. Prev: <A HREF="../b/boolean_operations" TYPE="Prev">Boolean Operations</A>  
  4. Up: <A HREF="../t/types" TYPE="Up">Types</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H2>2.1.3. Comparisons</H2>
  7. Comparison operations are supported by all objects.  They all have the
  8. same priority (which is higher than that of the Boolean operations).
  9. Comparisons can be chained arbitrarily, e.g. <CODE>x < y <= z</CODE> is
  10. equivalent to <CODE>x < y and y <= z</CODE>, except that <CODE>y</CODE> is
  11. evaluated only once (but in both cases <CODE>z</CODE> is not evaluated at
  12. all when <CODE>x < y</CODE> is found to be false).
  13. This table summarizes the comparison operations:
  14. <P>
  15. <DL>
  16. <DT><I>Operation</I><DD><I>Meaning</I>  ---  <I>Notes</I>
  17. <P>
  18. <DT><CODE><</CODE><DD>strictly less than
  19. <DT><CODE><=</CODE><DD>less than or equal
  20. <DT><CODE>></CODE><DD>strictly greater than
  21. <DT><CODE>>=</CODE><DD>greater than or equal
  22. <DT><CODE>==</CODE><DD>equal
  23. <DT><CODE><></CODE><DD>not equal  ---  (1)
  24. <DT><CODE>!=</CODE><DD>not equal  ---  (1)
  25. <DT><CODE>is</CODE><DD>object identity
  26. <DT><CODE>is not</CODE><DD>negated object identity
  27. </DL>
  28.  Notes:
  29. <P>
  30. <DL>
  31. <DT><B>(1)</B><DD><CODE><></CODE> and <CODE>!=</CODE> are alternate spellings for the same operator.
  32. (I couldn't choose between ABC and C! :-)
  33. </DL>
  34. Objects of different types, except different numeric types, never
  35. compare equal; such objects are ordered consistently but arbitrarily
  36. (so that sorting a heterogeneous array yields a consistent result).
  37. Furthermore, some types (e.g., windows) support only a degenerate
  38. notion of comparison where any two objects of that type are unequal.
  39. Again, such objects are ordered arbitrarily but consistently.
  40. (Implementation note: objects of different types except numbers are
  41. ordered by their type names; objects of the same types that don't
  42. support proper comparison are ordered by their address.)
  43. <P>
  44. Two more operations with the same syntactic priority, <CODE>in</CODE> and
  45. <CODE>not in</CODE>, are supported only by sequence types (below).
  46.