Python Standard Operators and Functions


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.



Core Python Programming
Core Python Programming (2nd Edition)
ISBN: 0132269937
EAN: 2147483647
Year: 2004
Pages: 334
Authors: Wesley J Chun

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net