home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
c
/
comparison
< prev
next >
Wrap
Text File
|
1996-11-14
|
2KB
|
46 lines
<TITLE>Comparisons -- Python library reference</TITLE>
Next: <A HREF="../n/numeric_types" TYPE="Next">Numeric Types</A>
Prev: <A HREF="../b/boolean_operations" TYPE="Prev">Boolean Operations</A>
Up: <A HREF="../t/types" TYPE="Up">Types</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H2>2.1.3. Comparisons</H2>
Comparison operations are supported by all objects. They all have the
same priority (which is higher than that of the Boolean operations).
Comparisons can be chained arbitrarily, e.g. <CODE>x < y <= z</CODE> is
equivalent to <CODE>x < y and y <= z</CODE>, except that <CODE>y</CODE> is
evaluated only once (but in both cases <CODE>z</CODE> is not evaluated at
all when <CODE>x < y</CODE> is found to be false).
This table summarizes the comparison operations:
<P>
<DL>
<DT><I>Operation</I><DD><I>Meaning</I> --- <I>Notes</I>
<P>
<DT><CODE><</CODE><DD>strictly less than
<DT><CODE><=</CODE><DD>less than or equal
<DT><CODE>></CODE><DD>strictly greater than
<DT><CODE>>=</CODE><DD>greater than or equal
<DT><CODE>==</CODE><DD>equal
<DT><CODE><></CODE><DD>not equal --- (1)
<DT><CODE>!=</CODE><DD>not equal --- (1)
<DT><CODE>is</CODE><DD>object identity
<DT><CODE>is not</CODE><DD>negated object identity
</DL>
Notes:
<P>
<DL>
<DT><B>(1)</B><DD><CODE><></CODE> and <CODE>!=</CODE> are alternate spellings for the same operator.
(I couldn't choose between ABC and C! :-)
</DL>
Objects of different types, except different numeric types, never
compare equal; such objects are ordered consistently but arbitrarily
(so that sorting a heterogeneous array yields a consistent result).
Furthermore, some types (e.g., windows) support only a degenerate
notion of comparison where any two objects of that type are unequal.
Again, such objects are ordered arbitrarily but consistently.
(Implementation note: objects of different types except numbers are
ordered by their type names; objects of the same types that don't
support proper comparison are ordered by their address.)
<P>
Two more operations with the same syntactic priority, <CODE>in</CODE> and
<CODE>not in</CODE>, are supported only by sequence types (below).