Table B.2 represents the operators and (built-in and factory) functions that can be used with most standard Python objects as well as user-defined objects in which you have implemented their corresponding special methods.
Table B.2. Standard Type Operators and Functions
Operator/function
Description
Result[a]
String representation
''
Evaluatable string representation
str
Built-in and factory functions
cmp(obj1, obj2)
Compares two objects
int
repr(obj)
Evaluatable string representation
str
str(obj)
Printable string representation
str
type(obj)
Object type
type
Value comparisons
<
Less than
bool
>
Greater than
bool
<=
Less than or equal to
bool
>=
Greater than or equal to
bool
==
Equal to
bool
!=
Not equal to
bool
<>
Not equal to
bool
Object comparisons
is
The same as
bool
is not
Not the same as
bool
Boolean operators
not
Logical negation
bool
and
Logical conjunction
bool
or
Logical disjunction
bool
[a] Boolean comparisons return either true or False.