1.1 Best case: trivial installation

intro.html | intro.html | new-standard.html | Installing Python Modules | contents.html
---
## 1.1 Best case: trivial installation
In the best case, someone will have prepared a special version of the
module distribution you want to install that is targeted specifically at
your platform and is installed just like any other software on your
platform. For example, the module developer might make an executable
installer available for Windows users, an RPM package for users of
RPM-based Linux systems (Red Hat, SuSE, Mandrake, and many others), a
Debian package for users of Debian-based Linux systems (Debian proper,
Caldera, Corel, etc.), and so forth.
In that case, you would download the installer appropriate to your
platform and do the obvious thing with it: run it if it's an executable
installer, `rpm -install` it if it's an RPM, etc. You don't need
to run Python or a setup script, you don't need to compile
anything--you might not even need to read any instructions (although
it's always a good idea to do so anyways).
Of course, things will not always be that easy. You might be interested
in a module distribution that doesn't have an easy-to-use installer for
your platform. In that case, you'll have to start with the source
distribution released by the module's author/maintainer. Installing
from a source distribution is not too hard, as long as the modules are
packaged in the standard way. The bulk of this document is about
building and installing modules from standard source distributions.


1.1 Best case: trivial installation


3.1 Tweaking compiler/linker flags

building-ext.html | building-ext.html | non-ms-compilers.html | Installing Python Modules | contents.html
---
## 3.1 Tweaking compiler/linker flags


About this document ...

genindex.html | lib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# About this document ...
Python Library Reference,
October 16, 2000, Release 2.0
This document was generated using the LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) translator.
LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) is Copyright ©
1993, 1994, 1995, 1996, 1997, Nikos
Drakos (http://cbl.leeds.ac.uk/nikos/personal.html), Computer Based Learning Unit, University of
Leeds, and Copyright © 1997, 1998, Ross
Moore (http://www.maths.mq.edu.au/~ross/), Mathematics Department, Macquarie University,
Sydney.
The application of LaTeX2HTML (http://saftsack.fs.uni-bayreuth.de/~latex2ht/) to the Python
documentation has been heavily tailored by Fred L. Drake,
Jr. Original navigation icons were contributed by Christopher
Petrilli.
---
## Comments and Questions
General comments and questions regarding this document should
be sent by email to python-docs@python.org (mailto:python-docs@python.org). If you find specific errors in
this document, please report the bug at the Python Bug
Tracker (http://sourceforge.net/bugs/?group_id=5470) at SourceForge (http://sourceforge.net/).
Questions regarding how to use the information in this
document should be sent to the Python news group, comp.lang.python (news:comp.lang.python), or the Python mailing list (http://www.python.org/mailman/listinfo/python-list) (which is gated to the newsgroup and
carries the same content).
For any of these channels, please be sure not to send HTML email.
Thanks.
---
genindex.html | lib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---


12.2.2 AddressList Objects

message-objects.html | module-rfc822.html | module-mimetools.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.2.2 AddressList Objects
An AddressList instance has the following methods:
Finally, AddressList instances have one public instance variable:


18.1.1 Configuration Objects

module-al.html | module-al.html | al-port-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.1.1 Configuration Objects
Configuration objects (returned by newconfig() have the
following methods:


18.1.2 Port Objects

al-config-objects.html | module-al.html | module-al-constants.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.1.2 Port Objects
Port objects, as returned by openport(), have the following
methods:


6. Generic Operating System Services

shlex-objects.html | lib.html | module-os.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 6. Generic Operating System Services
The modules described in this chapter provide interfaces to operating
system features that are available on (almost) all operating systems,
such as files and a clock. The interfaces are generally modeled
after the Unix or C interfaces, but they are available on most
other systems as well. Here's an overview:


17.1.4 Exceptions and Error Handling

Querying_ASTs.html | module-parser.html | AST_Objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.1.4 Exceptions and Error Handling
The parser module defines a single exception, but may also pass other
built-in exceptions from other portions of the Python runtime
environment. See each function for information about the exceptions
it can raise.
Note that the functions compileast(), expr(), and
suite() may throw exceptions which are normally thrown by the
parsing and compilation process. These include the built in
exceptions MemoryError, OverflowError,
SyntaxError, and SystemError. In these cases, these
exceptions carry all the meaning normally associated with them. Refer
to the descriptions of each function for detailed information.


17.1.6 Examples

AST_Objects.html | module-parser.html | node376.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.1.6 Examples
The parser modules allows operations to be performed on the parse tree
of Python source code before the bytecode is generated, and provides
for inspection of the parse tree for information gathering purposes.
Two examples are presented. The simple example demonstrates emulation
of the compile() built-in function and
the complex example shows the use of a parse tree for information
discovery.


17.1.5 AST Objects

AST_Errors.html | module-parser.html | AST_Examples.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.1.5 AST Objects
Ordered and equality comparisons are supported between AST objects.
Pickling of AST objects (using the pickle (module-pickle.html) module) is also
supported.
AST objects have the following methods:


11.18.1 Example basic HTTP client

module-asyncore.html | module-asyncore.html | netdata.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.18.1 Example basic HTTP client
As a basic example, below is a very basic HTTP client that uses the
dispatcher class to implement its socket handling:
```text

class http_client(asyncore.dispatcher):
def __init__(self, host,path):
asyncore.dispatcher.__init__(self)
self.path = path
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect( (host, 80) )
self.buffer = 'GET %s HTTP/1.0\r\b\r\n' % self.path

def handle_connect(self):
pass

def handle_read(self):
data = self.recv(8192)
print data

def writeable(self):
return (len(self.buffer) > 0)

def handle_write(self):
sent = self.send(self.buffer)
self.buffer = self.buffer[sent:]
```


3.3.1 atexit Example

module-atexit.html | module-atexit.html | module-types.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 3.3.1 atexit Example
The following simple example demonstrates how a module can initialize
a counter from a file when it is imported and save the counter's
updated value automatically when the program terminates without
relying on the application making an explicit call into this module at
termination.


13.8.5 AttributesImpl Objects

input-source-objects.html | module-xml.sax.xmlreader.html | attributes-ns-impl-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.8.5 AttributesImpl Objects
AttributesImpl objects implement a portion of the mapping
protocol, and the methods copy(), get(),
has_key(), items(), keys(), and
values(). The following methods are also provided:


13.8.6 AttributesNSImpl Objects

attributes-impl-objects.html | module-xml.sax.xmlreader.html | module-xmllib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.8.6 AttributesNSImpl Objects


14.4.1 AU_read Objects

module-sunau.html | module-sunau.html | au-write-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 14.4.1 AU_read Objects
AU_read objects, as returned by open() above, have the
following methods:
The following two methods define a term ``position'' which is compatible
between them, and is otherwise implementation dependent.
The following two functions are defined for compatibility with the
aifc (module-aifc.html), and don't do anything interesting.


14.4.2 AU_write Objects

au-read-objects.html | module-sunau.html | module-wave.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 14.4.2 AU_write Objects
AU_write objects, as returned by open() above, have the
following methods:


19.1.1 Audio Device Objects

module-sunaudiodev.html | module-sunaudiodev.html | module-sunaudiodev-constants.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 19.1.1 Audio Device Objects
The audio device objects are returned by open() define the
following methods (except `control` objects which only provide
getinfo(), setinfo(), fileno(), and
drain()):
The audio device supports asynchronous notification of various events,
through the SIGPOLL signal. Here's an example of how you might enable
this in Python:
```text

def handle_sigpoll(signum, frame):
print 'I got a SIGPOLL update'

import fcntl, signal, STROPTS

signal.signal(signal.SIGPOLL, handle_sigpoll)
fcntl.ioctl(audio_obj.fileno(), STROPTS.I_SETSIG, STROPTS.S_MSG)
```


12.6.1 Notes

module-binhex.html | module-binhex.html | module-uu.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.6.1 Notes
There is an alternative, more powerful interface to the coder and
decoder, see the source for details.
If you code or decode textfiles on non-Macintosh platforms they will
still use the Macintosh newline convention (carriage-return as end of
line).


5.5.1 Example

module-bisect.html | module-bisect.html | module-array.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 5.5.1 Example
The bisect() function is generally useful for categorizing
numeric data. This example uses bisect() to look up a
letter grade for an exam total (say) based on a set of ordered numeric
breakpoints: 85 and up is an `A', 75..84 is a `B', etc.


typesnumeric.html | typesnumeric.html | typesseq.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.4.1 Bit-string Operations on Integer Types
Plain and long integer types support additional operations that make
sense only for bit-strings. Negative numbers are treated as their 2's
complement value (for long integers, this assumes a sufficiently large
number of bits that no overflow occurs during the operation).
The priorities of the binary bit-wise operations are all lower than
the numeric operations and higher than the comparisons; the unary
operation "~" has the same priority as the other unary numeric
operations ("+" and "-").
This table lists the bit-string operations sorted in ascending
priority (operations in the same box have the same priority):
Notes:
(1): Negative shift counts are illegal and cause a
ValueError to be raised.
(2): A left shift by n bits is equivalent to
multiplication by `pow(2, n )` without overflow check.
(3): A right shift by n bits is equivalent to
division by `pow(2, n )` without overflow check.


2.1.7.5 Code Objects

typesmethods.html | typesother.html | bltin-type-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.7.5 Code Objects
Code objects are used by the implementation to represent
``pseudo-compiled'' executable Python code such as a function body.
They differ from function objects because they don't contain a
reference to their global execution environment. Code objects are
returned by the built-in compile() function and can be
extracted from function objects through their func_code
attribute.
A code object can be executed or evaluated by passing it (instead of a
source string) to the exec statement or the built-in
eval() function.
See the Python Reference Manual (../ref/ref.html) for more
information.


2.1.7.8 The Ellipsis Object

bltin-null-object.html | typesother.html | bltin-file-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.7.8 The Ellipsis Object
This object is used by extended slice notation (see the
Python Reference Manual (../ref/ref.html)). It supports no
special operations. There is exactly one ellipsis object, named
Ellipsis (a built-in name).
It is written as `Ellipsis`.


2.1.7.9 File Objects

bltin-ellipsis-object.html | typesother.html | typesinternal.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.7.9 File Objects
File objects are implemented using C's `stdio` package and can be
created with the built-in function
open() described in section
2.3 (built-in-funcs.html#built-in-funcs), ``Built-in Functions.'' They are also returned
by some other built-in functions and methods, e.g.,
os.popen() and os.fdopen() and the
makefile() method of socket objects.
When a file operation fails for an I/O-related reason, the exception
IOError is raised. This includes situations where the
operation is not defined for some reason, like seek() on a tty
device or writing a file opened for reading.
Files have the following methods:
File objects also offer a number of other interesting attributes.
These are not required for file-like objects, but should be
implemented if they make sense for the particular object.


2.1.7.7 The Null Object

bltin-type-objects.html | typesother.html | bltin-ellipsis-object.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.7.7 The Null Object
This object is returned by functions that don't explicitly return a
value. It supports no special operations. There is exactly one null
object, named `None` (a built-in name).
It is written as `None`.


2.1.7.6 Type Objects

bltin-code-objects.html | typesother.html | bltin-null-object.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 2.1.7.6 Type Objects
Type objects represent the various object types. An object's type is
accessed by the built-in function type(). There are no special
operations on types. The standard module types defines names
for all standard built-in types.
Types are written like this: `<type 'int'>`.


2.1.2 Boolean Operations

truth.html | types.html | comparisons.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 2.1.2 Boolean Operations
These are the Boolean operations, ordered by ascending priority:
Notes:
(1): These only evaluate their second argument if needed for their outcome.
(2): "not" has a lower priority than non-Boolean operators, so
`not a == b` is interpreted as `not ( a == b )`, and `a == not b` is a syntax error.


11.1.1 Browser Controller Objects

module-webbrowser.html | module-webbrowser.html | module-cgi.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.1.1 Browser Controller Objects
Browser controllers provide two methods which parallel two of the
module-level convenience functions:


7.13.1 Hash, BTree and Record Objects

module-bsddb.html | module-bsddb.html | module-zlib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.13.1 Hash, BTree and Record Objects
Once instantiated, hash, btree and record objects support the following
methods:
Example:


2.3 Built-in Functions

module-exceptions.html | builtin.html | python.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 2.3 Built-in Functions
The Python interpreter has a number of functions built into it that
are always available. They are listed here in alphabetical order.


intro.html | lib.html | types.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 2. Built-in Types, Exceptions and Functions
Names for built-in exceptions and functions are found in a separate
symbol table. This table is searched last when the interpreter looks
up the meaning of a name, so local and global
user-defined names can override built-in names. Built-in types are
described together here for easy reference.2.1 (#foot131)
The tables in this chapter document the priorities of operators by
listing them in order of ascending priority (within a table) and
grouping operators that have the same priority in the same box.
Binary operators of the same priority group from left to right.
(Unary operators group from right to left, but there you have no real
choice.) See chapter 5 of the Python
Reference Manual (../ref/ref.html) for the complete picture on operator priorities.
---
#### Footnotes


17.10.1 Python Byte Code Instructions

module-dis.html | module-dis.html | sgi.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.10.1 Python Byte Code Instructions
The Python compiler currently generates the following byte code
instructions.
Unary Operations take the top of the stack, apply the operation, and
push the result back on the stack.
Binary operations remove the top of the stack (TOS) and the second top-most
stack item (TOS1) from the stack. They perform the operation, and put the
result back on the stack.
In-place operations are like binary operations, in that they remove TOS and
TOS1, and push the result back on the stack, but the operation is done
in-place when TOS1 supports it, and the resulting TOS may be (but does not
have to be) the original TOS1.
The slice opcodes take up to three parameters.
Slice assignment needs even an additional parameter. As any statement,
they put nothing on the stack.
All of the following opcodes expect arguments. An argument is two
bytes, with the more significant byte last.


18.3.2 Parser Objects

player-objects.html | module-cd.html | module-fl.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.3.2 Parser Objects
Parser objects (returned by createparser()) have the
following methods:


11.2.1 Introduction

module-cgi.html | module-cgi.html | Using_the_cgi_module.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.2.1 Introduction
A CGI script is invoked by an HTTP server, usually to process user
input submitted through an HTML `<FORM>` or `<ISINDEX>` element.
Most often, CGI scripts live in the server's special cgi-bin
directory. The HTTP server places all sorts of information about the
request (such as the client's hostname, the requested URL, the query
string, and lots of other goodies) in the script's shell environment,
executes the script, and sends the script's output back to the client.
The script's input is connected to the client too, and sometimes the
form data is read this way; at other times the form data is passed via
the ``query string'' part of the URL. This module is intended
to take care of the different cases and provide a simpler interface to
the Python script. It also provides a number of utilities that help
in debugging scripts, and the latest addition is support for file
uploads from a form (if your browser supports it -- Grail 0.3 and
Netscape 2.0 do).
The output of a CGI script should consist of two sections, separated
by a blank line. The first section contains a number of headers,
telling the client what kind of data is following. Python code to
generate a minimal header section looks like this:
```text

print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
```
The second section is usually HTML, which allows the client software
to display nicely formatted text with header, in-line images, etc.
Here's Python code that prints a simple piece of HTML:
```text

print "<TITLE>CGI script output</TITLE>"
print "<H1>This is my first CGI script</H1>"
print "Hello, world!"
```


5.10.1 Cmd Objects

module-cmd.html | module-cmd.html | module-shlex.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 5.10.1 Cmd Objects
A Cmd instance has the following methods:
Instances of Cmd subclasses have some public instance variables:


4.7.1.1 Codec Objects

node80.html | node80.html | stream-writer-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
### 4.7.1.1 Codec Objects
The Codec class defines these methods which also define the
function interfaces of the stateless encoder and decoder:
The StreamWriter and StreamReader classes provide
generic working interfaces which can be used to implement new
encodings submodules very easily. See encodings.utf_8 for an
example on how this is done.


2.1.3 Comparisons

boolean.html | types.html | typesnumeric.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 2.1.3 Comparisons
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; for example, `x < y <= z` is equivalent to `x < y and y <= z`, except that y is evaluated only once (but
in both cases z is not evaluated at all when `x < y` is found to be false).
This table summarizes the comparison operations:
Notes:
(1): `<>` and `!=` are alternate spellings for the same operator.
(I couldn't choose between ABC and C! :-)
`!=` is the preferred spelling; `<>` is obsolescent.
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 (for example, file objects) support only a
degenerate notion of comparison where any two objects of that type are
unequal. Again, such objects are ordered arbitrarily but
consistently.
Instances of a class normally compare as non-equal unless the class
defines the __cmp__() method. Refer to the
Python Reference Manual (../ref/customization.html) for
information on the use of this method to effect object comparisons.
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.
Two more operations with the same syntactic priority,
"in" and "not in", are supported
only by sequence types (below).


7.18.1 Completer Objects

module-rlcompleter.html | module-rlcompleter.html | unix.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.18.1 Completer Objects
Completer objects have the following method:


7.5.3 Condition Objects

rlock-objects.html | module-threading.html | semaphore-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.5.3 Condition Objects
A condition variable is always associated with some kind of lock;
this can be passed in or one will be created by default. (Passing
one in is useful when several condition variables must share the
same lock.)
A condition variable has acquire() and release()
methods that call the corresponding methods of the associated lock.
It also has a wait() method, and notify() and
notifyAll() methods. These three must only be called when
the calling thread has acquired the lock.
The wait() method releases the lock, and then blocks until it
is awakened by a notify() or notifyAll() call for
the same condition variable in another thread. Once awakened, it
re-acquires the lock and returns. It is also possible to specify a
timeout.
The notify() method wakes up one of the threads waiting for
the condition variable, if any are waiting. The notifyAll()
method wakes up all threads waiting for the condition variable.
Note: the notify() and notifyAll() methods don't
release the lock; this means that the thread or threads awakened will
not return from their wait() call immediately, but only when
the thread that called notify() or notifyAll()
finally relinquishes ownership of the lock.
Tip: the typical programming style using condition variables uses the
lock to synchronize access to some shared state; threads that are
interested in a particular change of state call wait()
repeatedly until they see the desired state, while threads that modify
the state call notify() or notifyAll() when they
change the state in such a way that it could possibly be a desired
state for one of the waiters. For example, the following code is a
generic producer-consumer situation with unlimited buffer capacity:
```text

# Consume one item
cv.acquire()
while not an_item_is_available():
cv.wait()
get_an_available_item()
cv.release()

# Produce one item
cv.acquire()
make_an_item_available()
cv.notify()
cv.release()
```
To choose between notify() and notifyAll(), consider
whether one state change can be interesting for only one or several
waiting threads. E.g. in a typical producer-consumer situation,
adding one item to the buffer only needs to wake up one consumer
thread.


5.7.1 ConfigParser Objects

module-ConfigParser.html | module-ConfigParser.html | module-fileinput.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 5.7.1 ConfigParser Objects
ConfigParser instances have the following methods:


3.18.2 Interactive Console Objects

interpreter-objects.html | module-code.html | module-codeop.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 3.18.2 Interactive Console Objects
The InteractiveConsole class is a subclass of
InteractiveInterpreter, and so offers all the methods of the
interpreter objects as well as the following additions.


13.6.1 ContentHandler Objects

module-xml.sax.handler.html | module-xml.sax.handler.html | dtd-handler-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.6.1 ContentHandler Objects
Users are expected to subclass ContentHandler to support their
application. The following methods are called by the parser on the
appropriate events in the input document:


Contents

front.html | lib.html | intro.html | Python Library Reference | modindex.html | genindex.html
---
## Contents
Table of Contents
- Front Matter (front.html)
  1. Introduction (intro.html)
  2. Built-in Types, Exceptions and Functions (builtin.html)
  - 2.1 Built-in Types (types.html)
  - 2.1.1 Truth Value Testing (truth.html)
  2.1.2 Boolean Operations (boolean.html)
  2.1.3 Comparisons (comparisons.html)
  2.1.4 Numeric Types (typesnumeric.html)
  2.1.5 Sequence Types (typesseq.html)
  2.1.6 Mapping Types (typesmapping.html)
  2.1.7 Other Built-in Types (typesother.html)
  2.1.8 Special Attributes (specialattrs.html)
  2.2 Built-in Exceptions (module-exceptions.html)
  2.3 Built-in Functions (built-in-funcs.html)
  3. Python Runtime Services (python.html)
  - 3.1 sys --
  System-specific parameters and functions (module-sys.html)
  3.2 gc --
  Garbage Collector interface (module-gc.html)
  3.3 atexit --
  Exit handlers (module-atexit.html)
  - 3.3.1 atexit Example (atexit-example.html)
  3.4 types --
  Names for all built-in types (module-types.html)
  3.5 UserDict --
  Class wrapper for dictionary objects (module-UserDict.html)
  3.6 UserList --
  Class wrapper for list objects (module-UserList.html)
  3.7 UserString --
  Class wrapper for string objects (module-UserString.html)
  3.8 operator --
  Standard operators as functions. (module-operator.html)
  3.9 traceback --
  Print or retrieve a stack traceback (module-traceback.html)
  - 3.9.1 Traceback Example (traceback-example.html)
  3.10 linecache --
  Random access to text lines (module-linecache.html)
  3.11 pickle --
  Python object serialization (module-pickle.html)
  - 3.11.1 Example (pickle-example.html)
  3.12 cPickle --
  Alternate implementation of pickle (module-cPickle.html)
  3.13 copy_reg --
  Register pickle support functions (module-copyreg.html)
  3.14 shelve --
  Python object persistence (module-shelve.html)
  3.15 copy --
  Shallow and deep copy operations (module-copy.html)
  3.16 marshal --
  Alternate Python object serialization (module-marshal.html)
  3.17 imp --
  Access the import internals (module-imp.html)
  - 3.17.1 Examples (examples-imp.html)
  3.18 code --
  Interpreter base classes (module-code.html)
  - 3.18.1 Interactive Interpreter Objects (interpreter-objects.html)
  3.18.2 Interactive Console Objects (console-objects.html)
  3.19 codeop --
  Compile Python code (module-codeop.html)
  3.20 pprint --
  Data pretty printer (module-pprint.html)
  - 3.20.1 PrettyPrinter Objects (PrettyPrinter_Objects.html)
  3.21 repr --
  Alternate repr() implementation (module-repr.html)
  - 3.21.1 Repr Objects (Repr-objects.html)
  3.21.2 Subclassing Repr Objects (subclassing-reprs.html)
  3.22 new --
  Creation of runtime internal objects (module-new.html)
  3.23 site --
  Site-specific configuration hook (module-site.html)
  3.24 user --
  User-specific configuration hook (module-user.html)
  3.25 __builtin__ --
  Built-in functions (module-builtin.html)
  3.26 __main__ --
  Top-level script environment (module-main.html)
  4. String Services (strings.html)
  - 4.1 string --
  Common string operations (module-string.html)
  4.2 re --
  Regular expression operations (module-re.html)
  - 4.2.1 Regular Expression Syntax (re-syntax.html)
  4.2.2 Matching vs. Searching (matching-searching.html)
  4.2.3 Module Contents (Contents_of_Module_re.html)
  4.2.4 Regular Expression Objects (re-objects.html)
  4.2.5 Match Objects (match-objects.html)
  4.3 struct --
  Interpret strings as packed binary data (module-struct.html)
  4.4 fpformat --
  Floating point conversions (module-fpformat.html)
  4.5 StringIO --
  Read and write strings as files (module-StringIO.html)
  4.6 cStringIO --
  Faster version of StringIO (module-cStringIO.html)
  4.7 codecs --
  Codec registry and base classes (module-codecs.html)
  - 4.7.1 Codec Base Classes (node80.html)
  4.8 unicodedata --
  Unicode Database (module-unicodedata.html)
  5. Miscellaneous Services (misc.html)
  - 5.1 math --
  Mathematical functions (module-math.html)
  5.2 cmath --
  Mathematical functions for complex numbers (module-cmath.html)
  5.3 random --
  Generate pseudo-random numbers (module-random.html)
  - 5.3.1 The Random Number Generator Interface (rng-objects.html)
  5.4 whrandom --
  Pseudo-random number generator (module-whrandom.html)
  5.5 bisect --
  Array bisection algorithm (module-bisect.html)
  - 5.5.1 Example (bisect-example.html)
  5.6 array --
  Efficient arrays of numeric values (module-array.html)
  5.7 ConfigParser --
  Configuration file parser (module-ConfigParser.html)
  - 5.7.1 ConfigParser Objects (ConfigParser-objects.html)
  5.8 fileinput --
  Iterate over lines from multiple input streams (module-fileinput.html)
  5.9 calendar --
  General calendar-related functions (module-calendar.html)
  5.10 cmd --
  Support for line-oriented command interpreters (module-cmd.html)
  - 5.10.1 Cmd Objects (Cmd-objects.html)
  5.11 shlex --
  Simple lexical analysis (module-shlex.html)
  - 5.11.1 shlex Objects (shlex-objects.html)
  6. Generic Operating System Services (allos.html)
  - 6.1 os --
  Miscellaneous OS interfaces (module-os.html)
  - 6.1.1 Process Parameters (os-procinfo.html)
  6.1.2 File Object Creation (os-newstreams.html)
  6.1.3 File Descriptor Operations (os-fd-ops.html)
  6.1.4 Files and Directories (os-file-dir.html)
  6.1.5 Process Management (os-process.html)
  6.1.6 Miscellaneous System Information (os-path.html)
  6.2 os.path --
  Common pathname manipulations (module-os.path.html)
  6.3 dircache --
  Cached directory listings (module-dircache.html)
  6.4 stat --
  Interpreting stat() results (module-stat.html)
  6.5 statcache --
  An optimization of os.stat() (module-statcache.html)
  6.6 statvfs --
  Constants used with os.statvfs() (module-statvfs.html)
  6.7 filecmp --
  File and Directory Comparisons (module-filecmp.html)
  - 6.7.1 The dircmp class (dircmp-objects.html)
  6.8 popen2 --
  Subprocesses with accessible I/O streams (module-popen2.html)
  - 6.8.1 Popen3 and Popen4 Objects (popen3-objects.html)
  6.9 time --
  Time access and conversions (module-time.html)
  6.10 sched --
  Event scheduler (module-sched.html)
  - 6.10.1 Scheduler Objects (scheduler-objects.html)
  6.11 getpass
  -- Portable password input (module-getpass.html)
  6.12 curses --
  Terminal handling for character-cell displays (module-curses.html)
  - 6.12.1 Functions (curses-functions.html)
  6.12.2 Window Objects (curses-window-objects.html)
  6.12.3 Constants (node128.html)
  6.13 curses.textpad --
  Text input widget for curses programs (module-curses.textpad.html)
  - 6.13.1 Textbox objects (curses-textpad-objects.html)
  6.14 curses.wrapper --
  Terminal handler for curses programs (module-curses.wrapper.html)
  6.15 curses.ascii --
  Utilities for ASCII characters (module-curses.ascii.html)
  6.16 getopt --
  Parser for command line options (module-getopt.html)
  6.17 tempfile --
  Generate temporary file names (module-tempfile.html)
  6.18 errno --
  Standard errno system symbols (module-errno.html)
  6.19 glob --
  Unix style pathname pattern expansion (module-glob.html)
  6.20 fnmatch --
  Unix filename pattern matching (module-fnmatch.html)
  6.21 shutil --
  High-level file operations (module-shutil.html)
  - 6.21.1 Example (shutil-example.html)
  6.22 locale --
  Internationalization services (module-locale.html)
  - 6.22.1 Background, details, hints, tips and caveats (node141.html)
  6.22.2 For extension writers and programs that embed Python (embedding-locale.html)
  6.23 gettext --
  Multilingual internationalization services (module-gettext.html)
  - 6.23.1 GNU gettext API (node144.html)
  6.23.2 Class-based API (node145.html)
  6.23.3 Internationalizing your programs and modules (node150.html)
  6.23.4 Acknowledgements (node155.html)
  7. Optional Operating System Services (someos.html)
  - 7.1 signal --
  Set handlers for asynchronous events (module-signal.html)
  - 7.1.1 Example (Signal_Example.html)
  7.2 socket --
  Low-level networking interface (module-socket.html)
  - 7.2.1 Socket Objects (socket-objects.html)
  7.2.2 Example (socket-example.html)
  7.3 select --
  Waiting for I/O completion (module-select.html)
  - 7.3.1 Polling Objects (poll-objects.html)
  7.4 thread --
  Multiple threads of control (module-thread.html)
  7.5 threading --
  Higher-level threading interface (module-threading.html)
  - 7.5.1 Lock Objects (lock-objects.html)
  7.5.2 RLock Objects (rlock-objects.html)
  7.5.3 Condition Objects (condition-objects.html)
  7.5.4 Semaphore Objects (semaphore-objects.html)
  7.5.5 Event Objects (event-objects.html)
  7.5.6 Thread Objects (thread-objects.html)
  7.6 mutex --
  Mutual exclusion support (module-mutex.html)
  - 7.6.1 Mutex Objects (mutex-objects.html)
  7.7 Queue --
  A synchronized queue class (module-Queue.html)
  - 7.7.1 Queue Objects (QueueObjects.html)
  7.8 mmap --
  Memory-mapped file support (module-mmap.html)
  7.9 anydbm --
  Generic access to DBM-style databases (module-anydbm.html)
  7.10 dumbdbm --
  Portable DBM implementation (module-dumbdbm.html)
  7.11 dbhash --
  DBM-style interface to the BSD database library (module-dbhash.html)
  - 7.11.1 Database Objects (dbhash-objects.html)
  7.12 whichdb --
  Guess which DBM module created a database (module-whichdb.html)
  7.13 bsddb --
  Interface to Berkeley DB library (module-bsddb.html)
  - 7.13.1 Hash, BTree and Record Objects (bsddb-objects.html)
  7.14 zlib --
  Compression compatible with gzip (module-zlib.html)
  7.15 gzip --
  Support for gzip files (module-gzip.html)
  7.16 zipfile --
  Work with ZIP archives (module-zipfile.html)
  - 7.16.1 ZipFile Objects (zipfile-objects.html)
  7.16.2 PyZipFile Objects (pyzipfile-objects.html)
  7.16.3 ZipInfo Objects (zipinfo-objects.html)
  7.17 readline --
  GNU readline interface (module-readline.html)
  - 7.17.1 Example (readline-example.html)
  7.18 rlcompleter --
  Completion function for GNU readline (module-rlcompleter.html)
  - 7.18.1 Completer Objects (completer-objects.html)
  8. Unix Specific Services (unix.html)
  - 8.1 posix --
  The most common POSIX system calls (module-posix.html)
  - 8.1.1 Large File Support (posix-large-files.html)
  8.1.2 Module Contents (posix-contents.html)
  8.2 pwd --
  The password database (module-pwd.html)
  8.3 grp --
  The group database (module-grp.html)
  8.4 crypt --
  Function to check Unix passwords (module-crypt.html)
  8.5 dl --
  Call C functions in shared objects (module-dl.html)
  - 8.5.1 Dl Objects (dl-objects.html)
  8.6 dbm --
  Simple ``database'' interface (module-dbm.html)
  8.7 gdbm --
  GNU's reinterpretation of dbm (module-gdbm.html)
  8.8 termios --
  POSIX style tty control (module-termios.html)
  - 8.8.1 Example (termios_Example.html)
  8.9 TERMIOS --
  Constants used with the termios module (module-TERMIOSuppercase.html)
  8.10 tty --
  Terminal control functions (module-tty.html)
  8.11 pty --
  Pseudo-terminal utilities (module-pty.html)
  8.12 fcntl --
  The fcntl() and ioctl() system calls (module-fcntl.html)
  8.13 pipes --
  Interface to shell pipelines (module-pipes.html)
  - 8.13.1 Template Objects (template-objects.html)
  8.14 posixfile --
  File-like objects with locking support (module-posixfile.html)
  8.15 resource --
  Resource usage information (module-resource.html)
  - 8.15.1 Resource Limits (node215.html)
  8.15.2 Resource Usage (node216.html)
  8.16 nis --
  Interface to Sun's NIS (Yellow Pages) (module-nis.html)
  8.17 syslog --
  Unix syslog library routines (module-syslog.html)
  8.18 commands --
  Utilities for running commands (module-commands.html)
  9. The Python Debugger (module-pdb.html)
  - 9.1 Debugger Commands (debugger-commands.html)
  9.2 How It Works (node222.html)
  10. The Python Profiler (profile.html)
  - 10.1 Introduction to the profiler (Profiler_Introduction.html)
  10.2 How Is This Profiler Different From The Old Profiler? (Profiler_Changes.html)
  10.3 Instant Users Manual (profile-instant.html)
  10.4 What Is Deterministic Profiling? (Deterministic_Profiling.html)
  10.5 Reference Manual (module-profile.html)
  - 10.5.1 The Stats Class (profile-stats.html)
  10.6 Limitations (profile-limits.html)
  10.7 Calibration (profile-calibration.html)
  10.8 Extensions -- Deriving Better Profilers (Profiler_Extensions.html)
  - 10.8.1 OldProfile Class (profile-old.html)
  10.8.2 HotProfile Class (profile-HotProfile.html)
  11. Internet Protocols and Support (internet.html)
  - 11.1 webbrowser --
  Convenient Web-browser controller (module-webbrowser.html)
  - 11.1.1 Browser Controller Objects (browser-controllers.html)
  11.2 cgi --
  Common Gateway Interface support. (module-cgi.html)
  - 11.2.1 Introduction (cgi-intro.html)
  11.2.2 Using the cgi module (Using_the_cgi_module.html)
  11.2.3 Old classes (node241.html)
  11.2.4 Functions (Functions_in_cgi_module.html)
  11.2.5 Caring about security (node243.html)
  11.2.6 Installing your CGI script on a Unix system (node244.html)
  11.2.7 Testing your CGI script (node245.html)
  11.2.8 Debugging CGI scripts (node246.html)
  11.2.9 Common problems and solutions (node247.html)
  11.3 urllib --
  Open arbitrary resources by URL (module-urllib.html)
  - 11.3.1 URLopener Objects (urlopener-objs.html)
  11.3.2 Examples (Urllib_Examples.html)
  11.4 httplib --
  HTTP protocol client (module-httplib.html)
  - 11.4.1 HTTP Objects (node252.html)
  11.4.2 Examples (HTTP_Examples.html)
  11.5 ftplib --
  FTP protocol client (module-ftplib.html)
  - 11.5.1 FTP Objects (ftp-objects.html)
  11.6 gopherlib --
  Gopher protocol client (module-gopherlib.html)
  11.7 poplib --
  POP3 protocol client (module-poplib.html)
  - 11.7.1 POP3 Objects (pop3-objects.html)
  11.7.2 POP3 Example (pop3-example.html)
  11.8 imaplib --
  IMAP4 protocol client (module-imaplib.html)
  - 11.8.1 IMAP4 Objects (imap4-objects.html)
  11.8.2 IMAP4 Example (imap4-example.html)
  11.9 nntplib --
  NNTP protocol client (module-nntplib.html)
  - 11.9.1 NNTP Objects (nntp-objects.html)
  11.10 smtplib --
  SMTP protocol client (module-smtplib.html)
  - 11.10.1 SMTP Objects (SMTP-objects.html)
  11.10.2 SMTP Example (SMTP-example.html)
  11.11 telnetlib --
  Telnet client (module-telnetlib.html)
  - 11.11.1 Telnet Objects (telnet-objects.html)
  11.11.2 Telnet Example (telnet-example.html)
  11.12 urlparse --
  Parse URLs into components (module-urlparse.html)
  11.13 SocketServer --
  A framework for network servers (module-SocketServer.html)
  11.14 BaseHTTPServer --
  Basic HTTP server (module-BaseHTTPServer.html)
  11.15 SimpleHTTPServer --
  Simple HTTP request handler (module-SimpleHTTPServer.html)
  11.16 CGIHTTPServer --
  CGI-capable HTTP request handler (module-CGIHTTPServer.html)
  11.17 Cookie --
  HTTP state management (module-Cookie.html)
  - 11.17.1 Cookie Objects (cookie-objects.html)
  11.17.2 Morsel Objects (morsel-objects.html)
  11.17.3 Example (cookie-example.html)
  11.18 asyncore --
  Asynchronous socket handler (module-asyncore.html)
  - 11.18.1 Example basic HTTP client (asyncore-example.html)
  12. Internet Data Handling (netdata.html)
  - 12.1 formatter --
  Generic output formatting (module-formatter.html)
  - 12.1.1 The Formatter Interface (formatter-interface.html)
  12.1.2 Formatter Implementations (formatter-impls.html)
  12.1.3 The Writer Interface (writer-interface.html)
  12.1.4 Writer Implementations (writer-impls.html)
  12.2 rfc822 --
  Parse RFC 822 mail headers (module-rfc822.html)
  - 12.2.1 Message Objects (message-objects.html)
  12.2.2 AddressList Objects (addresslist-objects.html)
  12.3 mimetools --
  Tools for parsing MIME messages (module-mimetools.html)
  - 12.3.1 Additional Methods of Message Objects (mimetools-message-objects.html)
  12.4 MimeWriter --
  Generic MIME file writer (module-MimeWriter.html)
  - 12.4.1 MimeWriter Objects (MimeWriter-objects.html)
  12.5 multifile --
  Support for files containing distinct parts (module-multifile.html)
  - 12.5.1 MultiFile Objects (MultiFile-objects.html)
  12.5.2 MultiFile Example (multifile-example.html)
  12.6 binhex --
  Encode and decode binhex4 files (module-binhex.html)
  - 12.6.1 Notes (binhex-notes.html)
  12.7 uu --
  Encode and decode uuencode files (module-uu.html)
  12.8 binascii --
  Convert between binary and ASCII (module-binascii.html)
  12.9 xdrlib --
  Encode and decode XDR data (module-xdrlib.html)
  - 12.9.1 Packer Objects (xdr-packer-objects.html)
  12.9.2 Unpacker Objects (xdr-unpacker-objects.html)
  12.9.3 Exceptions (xdr-exceptions.html)
  12.10 mailcap --
  Mailcap file handling. (module-mailcap.html)
  12.11 mimetypes --
  Map filenames to MIME types (module-mimetypes.html)
  12.12 base64 --
  Encode and decode MIME base64 data (module-base64.html)
  12.13 quopri --
  Encode and decode MIME quoted-printable data (module-quopri.html)
  12.14 mailbox --
  Read various mailbox formats (module-mailbox.html)
  - 12.14.1 Mailbox Objects (mailbox-objects.html)
  12.15 mhlib --
  Access to MH mailboxes (module-mhlib.html)
  - 12.15.1 MH Objects (mh-objects.html)
  12.15.2 Folder Objects (mh-folder-objects.html)
  12.15.3 Message Objects (mh-message-objects.html)
  12.16 mimify --
  MIME processing of mail messages (module-mimify.html)
  12.17 netrc --
  netrc file processing (module-netrc.html)
  - 12.17.1 netrc Objects (netrc-objects.html)
  12.18 robotparser --
  Parser for robots.txt (module-robotparser.html)
  13. Structured Markup Processing Tools (markup.html)
  - 13.1 sgmllib --
  Simple SGML parser (module-sgmllib.html)
  13.2 htmllib --
  A parser for HTML documents (module-htmllib.html)
  - 13.2.1 HTMLParser Objects (html-parser-objects.html)
  13.3 htmlentitydefs --
  Definitions of HTML general entities (module-htmlentitydefs.html)
  13.4 xml.parsers.expat --
  Fast XML parsing using the Expat library (module-xml.parsers.expat.html)
  - 13.4.1 Example (expat-example.html)
  13.4.2 Expat error constants (expat-errors.html)
  13.5 xml.sax --
  Support for SAX2 parsers (module-xml.sax.html)
  - 13.5.1 SAXException Objects (sax-exception-objects.html)
  13.6 xml.sax.handler --
  Base classes for SAX handlers (module-xml.sax.handler.html)
  - 13.6.1 ContentHandler Objects (content-handler-objects.html)
  13.6.2 DTDHandler Objects (dtd-handler-objects.html)
  13.6.3 EntityResolver Objects (entity-resolver-objects.html)
  13.7 xml.sax.saxutils --
  SAX Utilities (module-xml.sax.saxutils.html)
  13.8 xml.sax.xmlreader --
  Interface for XML parsers (module-xml.sax.xmlreader.html)
  - 13.8.1 XMLReader Objects (xmlreader-objects.html)
  13.8.2 IncrementalParser Objects (incremental-parser-objects.html)
  13.8.3 Locator Objects (locator-objects.html)
  13.8.4 InputSource Objects (input-source-objects.html)
  13.8.5 AttributesImpl Objects (attributes-impl-objects.html)
  13.8.6 AttributesNSImpl Objects (attributes-ns-impl-objects.html)
  13.9 xmllib --
  A parser for XML documents (module-xmllib.html)
  - 13.9.1 XML Namespaces (xml-namespace.html)
  14. Multimedia Services (mmedia.html)
  - 14.1 audioop --
  Manipulate raw audio data (module-audioop.html)
  14.2 imageop --
  Manipulate raw image data (module-imageop.html)
  14.3 aifc --
  Read and write AIFF and AIFC files (module-aifc.html)
  14.4 sunau --
  Read and write Sun AU files (module-sunau.html)
  - 14.4.1 AU_read Objects (au-read-objects.html)
  14.4.2 AU_write Objects (au-write-objects.html)
  14.5 wave --
  Read and write WAV files (module-wave.html)
  - 14.5.1 Wave_read Objects (Wave-read-objects.html)
  14.5.2 Wave_write Objects (Wave-write-objects.html)
  14.6 chunk --
  Read IFF chunked data (module-chunk.html)
  14.7 colorsys --
  Conversions between color systems (module-colorsys.html)
  14.8 rgbimg --
  Read and write ``SGI RGB'' files (module-rgbimg.html)
  14.9 imghdr --
  Determine the type of an image (module-imghdr.html)
  14.10 sndhdr --
  Determine type of sound file (module-sndhdr.html)
  15. Cryptographic Services (crypto.html)
  - 15.1 md5 --
  MD5 message digest algorithm (module-md5.html)
  15.2 sha --
  SHA message digest algorithm (module-sha.html)
  15.3 mpz --
  GNU arbitrary magnitude integers (module-mpz.html)
  15.4 rotor --
  Enigma-like encryption and decryption (module-rotor.html)
  16. Restricted Execution (restricted.html)
  - 16.1 rexec --
  Restricted execution framework (module-rexec.html)
  - 16.1.1 An example (node366.html)
  16.2 Bastion --
  Restricting access to objects (module-Bastion.html)
  17. Python Language Services (language.html)
  - 17.1 parser --
  Access Python parse trees (module-parser.html)
  - 17.1.1 Creating AST Objects (Creating_ASTs.html)
  17.1.2 Converting AST Objects (Converting_ASTs.html)
  17.1.3 Queries on AST Objects (Querying_ASTs.html)
  17.1.4 Exceptions and Error Handling (AST_Errors.html)
  17.1.5 AST Objects (AST_Objects.html)
  17.1.6 Examples (AST_Examples.html)
  17.2 symbol --
  Constants used with Python parse trees (module-symbol.html)
  17.3 token --
  Constants used with Python parse trees (module-token.html)
  17.4 keyword --
  Testing for Python keywords (module-keyword.html)
  17.5 tokenize --
  Tokenizer for Python source (module-tokenize.html)
  17.6 tabnanny --
  Detection of ambiguous indentation (module-tabnanny.html)
  17.7 pyclbr --
  Python class browser support (module-pyclbr.html)
  - 17.7.1 Class Descriptor Objects (pyclbr-class-objects.html)
  17.8 py_compile --
  Compile Python source files (module-pycompile.html)
  17.9 compileall --
  Byte-compile Python libraries (module-compileall.html)
  17.10 dis --
  Disassembler for Python byte code (module-dis.html)
  - 17.10.1 Python Byte Code Instructions (bytecodes.html)
  18. SGI IRIX Specific Services (sgi.html)
  - 18.1 al --
  Audio functions on the SGI (module-al.html)
  - 18.1.1 Configuration Objects (al-config-objects.html)
  18.1.2 Port Objects (al-port-objects.html)
  18.2 AL --
  Constants used with the al module (module-al-constants.html)
  18.3 cd --
  CD-ROM access on SGI systems (module-cd.html)
  - 18.3.1 Player Objects (player-objects.html)
  18.3.2 Parser Objects (cd-parser-objects.html)
  18.4 fl --
  FORMS library interface for GUI applications (module-fl.html)
  - 18.4.1 Functions Defined in Module fl (FL_Functions.html)
  18.4.2 Form Objects (form-objects.html)
  18.4.3 FORMS Objects (forms-objects.html)
  18.5 FL --
  Constants used with the fl module (module-fl-constants.html)
  18.6 flp --
  Functions for loading stored FORMS designs (module-flp.html)
  18.7 fm --
  Font Manager interface (module-fm.html)
  18.8 gl --
  Graphics Library interface (module-gl.html)
  18.9 DEVICE --
  Constants used with the gl module (module-DEVICE.html)
  18.10 GL --
  Constants used with the gl module (module-gl-constants.html)
  18.11 imgfile --
  Support for SGI imglib files (module-imgfile.html)
  18.12 jpeg --
  Read and write JPEG files (module-jpeg.html)
  19. SunOS Specific Services (sunos.html)
  - 19.1 sunaudiodev --
  Access to Sun audio hardware (module-sunaudiodev.html)
  - 19.1.1 Audio Device Objects (audio-device-objects.html)
  19.2 SUNAUDIODEV --
  Constants used with sunaudiodev (module-sunaudiodev-constants.html)
  20. MS Windows Specific Services (node413.html)
  - 20.1 msvcrt -
  Useful routines from the MS VC++ runtime (module-msvcrt.html)
  - 20.1.1 File Operations (msvcrt-files.html)
  20.1.2 Console I/O (msvcrt-console.html)
  20.1.3 Other Functions (msvcrt-other.html)
  20.2 _winreg -
  Windows registry access (module--winreg.html)
  - 20.2.1 Registry handle objects (handle-object.html)
  20.3 winsound --
  Sound-playing interface for Windows (module-winsound.html)
  A. Undocumented Modules (undoc.html)
  - A.1 Frameworks (node422.html)
  A.2 Miscellaneous useful utilities (node423.html)
  A.3 Platform specific modules (node424.html)
  A.4 Multimedia (node425.html)
  A.5 Obsolete (obsolete-modules.html)
  A.6 SGI-specific Extension modules (node427.html)
  B. Reporting Bugs (reporting-bugs.html)
  Module Index (modindex.html)
  About this document ... (about.html)
End of Table of Contents


4.2.3 Module Contents

matching-searching.html | module-re.html | re-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 4.2.3 Module Contents
The module defines the following functions and constants, and an exception:


4.3.2 Module Contents

node91.html | module-regex.html | module-regsub.html | Python Library Reference | contents.html | genindex.html
---
## 4.3.2 Module Contents
The module defines these functions, and an exception:
Compiled regular expression objects support these methods:
Compiled regular expressions support these data attributes:


17.1.2 Converting AST Objects

Creating_ASTs.html | module-parser.html | Querying_ASTs.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.1.2 Converting AST Objects
AST objects, regardless of the input used to create them, may be
converted to parse trees represented as list- or tuple- trees, or may
be compiled into executable code objects. Parse trees may be
extracted with or without line numbering information.


11.17.3 Example

morsel-objects.html | module-Cookie.html | module-asyncore.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.17.3 Example
The following example demonstrates how to open a can of spam using the
spam module.


11.17.1 Cookie Objects

module-Cookie.html | module-Cookie.html | morsel-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.17.1 Cookie Objects
.


17.1.1 Creating AST Objects

module-parser.html | module-parser.html | Converting_ASTs.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 17.1.1 Creating AST Objects
AST objects may be created from source code or from a parse tree.
When creating an AST object from source, different functions are used
to create the `'eval'` and `'exec'` forms.


15. Cryptographic Services

module-sndhdr.html | lib.html | module-md5.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 15. Cryptographic Services
The modules described in this chapter implement various algorithms of
a cryptographic nature. They are available at the discretion of the
installation. Here's an overview:
md5 (module-md5.html) | RSA's MD5 message digest algorithm.
sha (module-sha.html) | NIST's secure hash algorithm, SHA.
mpz (module-mpz.html) | Interface to the GNU MP library for arbitrary
precision arithmetic.
rotor (module-rotor.html) | Enigma-like encryption and decryption.


6.12.1 Functions

module-curses.html | module-curses.html | curses-window-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 6.12.1 Functions
The module curses defines the following exception:
Note: Whenever x or y arguments to a function
or a method are optional, they default to the current cursor location.
Whenever attr is optional, it defaults to A_NORMAL.
The module curses defines the following functions:


6.13.1 Textbox objects

module-curses.textpad.html | module-curses.textpad.html | module-curses.wrapper.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 6.13.1 Textbox objects
You can instantiate a Textbox object as follows:
Textbox objects have the following methods:


6.12.2 Window Objects

curses-functions.html | module-curses.html | node128.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 6.12.2 Window Objects
Window objects, as returned by initscr() and
newwin() above, have the
following methods:


7.11.1 Database Objects

module-dbhash.html | module-dbhash.html | module-whichdb.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.11.1 Database Objects
The database objects returned by open() provide the methods
common to all the DBM-style databases. The following methods are
available in addition to the standard methods.


9.1 Debugger Commands

module-pdb.html | module-pdb.html | node222.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 9.1 Debugger Commands
The debugger recognizes the following commands. Most commands can be
abbreviated to one or two letters; e.g. "h(elp)" means that
either "h" or "help" can be used to enter the help
command (but not "he" or "hel", nor "H" or
"Help" or "HELP"). Arguments to commands must be
separated by whitespace (spaces or tabs). Optional arguments are
enclosed in square brackets ("[]") in the command syntax; the
square brackets must not be typed. Alternatives in the command syntax
are separated by a vertical bar ("|").
Entering a blank line repeats the last command entered. Exception: if
the last command was a "list" command, the next 11 lines are
listed.
Commands that the debugger doesn't recognize are assumed to be Python
statements and are executed in the context of the program being
debugged. Python statements can also be prefixed with an exclamation
point ("!"). This is a powerful way to inspect the program
being debugged; it is even possible to change a variable or call a
function. When an
exception occurs in such a statement, the exception name is printed
but the debugger's state is not changed.
Multiple commands may be entered on a single line, separated by
";;". (A single ";" is not used as it is
the separator for multiple commands in a line that is passed to
the Python parser.)
No intelligence is applied to separating the commands;
the input is split at the first ";;" pair, even if it is in
the middle of a quoted string.
The debugger supports aliases. Aliases can have parameters which
allows one a certain level of adaptability to the context under
examination.
If a file .pdbrc
exists in the user's home directory or in the current directory, it is
read in and executed as if it had been typed at the debugger prompt.
This is particularly useful for aliases. If both files exist, the one
in the home directory is read first and aliases defined there can be
overridden by the local file.
h(elp) [command]: Without argument, print the list of available commands. With a
command as argument, print help about that command. "help
pdb" displays the full documentation file; if the environment variable
$PAGER is defined, the file is piped through that command
instead. Since the command argument must be an identifier,
"help exec" must be entered to get help on the "!" command.
w(here): Print a stack trace, with the most recent frame at the bottom. An
arrow indicates the current frame, which determines the context of
most commands.
d(own): Move the current frame one level down in the stack trace
(to an newer frame).
u(p): Move the current frame one level up in the stack trace
(to a older frame).
b(reak) [[filename:]lineno`|`function[, condition]]: With a lineno argument, set a break there in the current
file. With a function argument, set a break at the first
executable statement within that function.
The line number may be prefixed with a filename and a colon,
to specify a breakpoint in another file (probably one that
hasn't been loaded yet). The file is searched on `sys.path`.
Note that each breakpoint is assigned a number to which all the other
breakpoint commands refer.
If a second argument is present, it is an expression which must
evaluate to true before the breakpoint is honored.
Without argument, list all breaks, including for each breakpoint,
the number of times that breakpoint has been hit, the current
ignore count, and the associated condition if any.
tbreak [[filename:]lineno`|`function[, condition]]: Temporary breakpoint, which is removed automatically when it is
first hit. The arguments are the same as break.
cl(ear) [bpnumber [bpnumber ...]]: With a space separated list of breakpoint numbers, clear those
breakpoints. Without argument, clear all breaks (but first
ask confirmation).
disable [bpnumber [bpnumber ...]]: Disables the breakpoints given as a space separated list of
breakpoint numbers. Disabling a breakpoint means it cannot cause
the program to stop execution, but unlike clearing a breakpoint, it
remains in the list of breakpoints and can be (re-)enabled.
enable [bpnumber [bpnumber ...]]: Enables the breakpoints specified.
ignore bpnumber [count]: Sets the ignore count for the given breakpoint number. If
count is omitted, the ignore count is set to 0. A breakpoint
becomes active when the ignore count is zero. When non-zero,
the count is decremented each time the breakpoint is reached
and the breakpoint is not disabled and any associated condition
evaluates to true.
condition bpnumber [condition]: Condition is an expression which must evaluate to true before
the breakpoint is honored. If condition is absent, any existing
condition is removed; i.e., the breakpoint is made unconditional.
s(tep): Execute the current line, stop at the first possible occasion
(either in a function that is called or on the next line in the
current function).
n(ext): Continue execution until the next line in the current function
is reached or it returns. (The difference between "next" and
"step" is that "step" stops inside a called function, while
"next" executes called functions at (nearly) full speed, only
stopping at the next line in the current function.)
r(eturn): Continue execution until the current function returns.
c(ont(inue)): Continue execution, only stop when a breakpoint is encountered.
l(ist) [first[, last]]: List source code for the current file. Without arguments, list 11
lines around the current line or continue the previous listing. With
one argument, list 11 lines around at that line. With two arguments,
list the given range; if the second argument is less than the first,
it is interpreted as a count.
a(rgs): Print the argument list of the current function.
p expression: Evaluate the expression in the current context and print its
value. (Note: "print" can also be used, but is not a debugger
command -- this executes the Python print statement.)
alias [name [command]]: Creates an alias called name that executes command. The
command must not be enclosed in quotes. Replaceable parameters
can be indicated by "%1", "%2", and so on, while "%*" is
replaced by all the parameters. If no command is given, the current
alias for name is shown. If no arguments are given, all
aliases are listed.
Aliases may be nested and can contain anything that can be
legally typed at the pdb prompt. Note that internal pdb commands
can be overridden by aliases. Such a command is
then hidden until the alias is removed. Aliasing is recursively
applied to the first word of the command line; all other words
in the line are left alone.
As an example, here are two useful aliases (especially when placed
in the .pdbrc file):
```text

#Print instance variables (usage "pi classInst")
alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
#Print instance variables in self
alias ps pi self
```
unalias name: Deletes the specified alias.
[!]statement: Execute the (one-line) statement in the context of
the current stack frame.
The exclamation point can be omitted unless the first word
of the statement resembles a debugger command.
To set a global variable, you can prefix the assignment
command with a "global" command on the same line, e.g.:
```text

(Pdb) global list_options; list_options = ['-l']
(Pdb)
```
q(uit): Quit from the debugger.
The program being executed is aborted.


10.4 What Is Deterministic Profiling?

profile-instant.html | profile.html | module-profile.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 10.4 What Is Deterministic Profiling?
Deterministic profiling is meant to reflect the fact that all
function call, function return, and exception events
are monitored, and precise timings are made for the intervals between
these events (during which time the user's code is executing). In
contrast, statistical profiling (which is not done by this
module) randomly samples the effective instruction pointer, and
deduces where time is being spent. The latter technique traditionally
involves less overhead (as the code does not need to be instrumented),
but provides only relative indications of where time is being spent.
In Python, since there is an interpreter active during execution, the
presence of instrumented code is not required to do deterministic
profiling. Python automatically provides a hook (optional
callback) for each event. In addition, the interpreted nature of
Python tends to add so much overhead to execution, that deterministic
profiling tends to only add small processing overhead in typical
applications. The result is that deterministic profiling is not that
expensive, yet provides extensive run time statistics about the
execution of a Python program.
Call count statistics can be used to identify bugs in code (surprising
counts), and to identify possible inline-expansion points (high call
counts). Internal time statistics can be used to identify ``hot
loops'' that should be carefully optimized. Cumulative time
statistics should be used to identify high level errors in the
selection of algorithms. Note that the unusual handling of cumulative
times in this profiler allows statistics for recursive implementations
of algorithms to be directly compared to iterative implementations.


6.7.1 The dircmp class

module-filecmp.html | module-filecmp.html | module-popen2.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 6.7.1 The dircmp class


8.5.1 Dl Objects

module-dl.html | module-dl.html | module-dbm.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 8.5.1 Dl Objects
Dl objects, as returned by open() above, have the
following methods:


13.6.2 DTDHandler Objects

content-handler-objects.html | module-xml.sax.handler.html | entity-resolver-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.6.2 DTDHandler Objects
DTDHandler instances provide the following methods:


node141.html | module-locale.html | module-gettext.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 6.22.2 For extension writers and programs that embed Python
Extension modules should never call setlocale(), except to
find out what the current locale is. But since the return value can
only be used portably to restore it, that is not very useful (except
perhaps to find out whether or not the locale is "C").
When Python is embedded in an application, if the application sets the
locale to something specific before initializing Python, that is
generally okay, and Python will use whatever locale is set,
except that the LC_NUMERIC locale should always be
"C".
The setlocale() function in the locale module
gives the Python programmer the impression that you can manipulate the
LC_NUMERIC locale setting, but this not the case at the C
level: C code will always find that the LC_NUMERIC locale
setting is "C". This is because too much would break when the
decimal point character is set to something else than a period
(e.g. the Python parser would break). Caveat: threads that run
without holding Python's global interpreter lock may occasionally find
that the numeric locale setting differs; this is because the only
portable way to implement this feature is to set the numeric locale
settings to what the user requests, extract the relevant
characteristics, and then restore the "C" numeric locale.


13.6.3 EntityResolver Objects

dtd-handler-objects.html | module-xml.sax.handler.html | module-xml.sax.saxutils.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.6.3 EntityResolver Objects


7.5.5 Event Objects

semaphore-objects.html | module-threading.html | thread-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.5.5 Event Objects
This is one of the simplest mechanisms for communication between
threads: one thread signals an event and one or more other threads
are waiting for it.
An event object manages an internal flag that can be set to true with
the set() method and reset to false with the clear() method. The
wait() method blocks until the flag is true.


3.17.1 Examples

module-imp.html | module-imp.html | module-code.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 3.17.1 Examples
The following function emulates what was the standard import statement
up to Python 1.4 (i.e., no hierarchical module names). (This
implementation wouldn't work in that version, since
find_module() has been extended and
load_module() has been added in 1.4.)
```text

import imp import sys

def __import__(name, globals=None, locals=None, fromlist=None):
# Fast path: see if the module has already been imported.
try:
return sys.modules[name]
except KeyError:
pass

# If any of the following calls raises an exception,
# there's a problem we can't handle -- let the caller handle it.

fp, pathname, description = imp.find_module(name)

try:
return imp.load_module(name, fp, pathname, description)
finally:
# Since we may exit via an exception, close fp explicitly.
if fp:
fp.close()
```


13.4.2 Expat error constants

expat-example.html | module-xml.parsers.expat.html | module-xml.sax.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.4.2 Expat error constants
The following table lists the error constants in the
`errors` object of the xml.parsers.expat module. These
constants are useful in interpreting some of the attributes of the
parser object after an error has occurred.
The `errors` object has the following attributes:


13.4.1 Example

module-xml.parsers.expat.html | module-xml.parsers.expat.html | expat-errors.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.4.1 Example
The following program defines three handlers that just print out their
arguments.
```text

import xml.parsers.expat

# 3 handler functions
def start_element(name, attrs):
print 'Start element:', name, attrs
def end_element(name):
print 'End element:', name
def char_data(data):
print 'Character data:', repr(data)

p = xml.parsers.expat.ParserCreate()

p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = char_data

p.Parse("""<?xml version="1.0"?>
<parent id="top"><child1 name="paul">Text goes here</child1>
<child2 name="fred">More text</child2>
</parent>""")
```
The output from this program is:
```text

Start element: parent {'id': 'top'}
Start element: child1 {'name': 'paul'}
Character data: 'Text goes here'
End element: child1
Character data: '\012'
Start element: child2 {'name': 'fred'}
Character data: 'More text'
End element: child2
Character data: '\012'
End element: parent
```


18.4.1 Functions Defined in Module fl

module-fl.html | module-fl.html | form-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.4.1 Functions Defined in Module fl
Module fl defines the following functions. For more
information about what they do, see the description of the equivalent
C function in the FORMS documentation:


18.4.2 Form Objects

FL_Functions.html | module-fl.html | forms-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.4.2 Form Objects
Form objects (returned by make_form() above) have the
following methods. Each method corresponds to a C function whose
name is prefixed with "fl_"; and whose first argument is a form
pointer; please refer to the official FORMS documentation for
descriptions.
All the add_*() methods return a Python object representing
the FORMS object. Methods of FORMS objects are described below. Most
kinds of FORMS object also have some methods specific to that kind;
these methods are listed here.
Form objects have the following data attributes; see the FORMS
documentation:


12.1.2 Formatter Implementations

formatter-interface.html | module-formatter.html | writer-interface.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.1.2 Formatter Implementations
Two implementations of formatter objects are provided by this module.
Most applications may use one of these classes without modification or
subclassing.


12.1.1 The Formatter Interface

module-formatter.html | module-formatter.html | formatter-impls.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.1.1 The Formatter Interface
Interfaces to create formatters are dependent on the specific
formatter class being instantiated. The interfaces described below
are the required interfaces which all formatters must support once
initialized.
One data element is defined at the module level:
The following attributes are defined for formatter instance objects:


18.4.3 FORMS Objects

form-objects.html | module-fl.html | module-fl-constants.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 18.4.3 FORMS Objects
Besides methods specific to particular kinds of FORMS objects, all
FORMS objects also have the following methods:
FORMS objects have these data attributes; see the FORMS documentation:


Front Matter

lib.html | lib.html | contents.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# Front Matter
BEOPEN.COM TERMS AND CONDITIONS FOR PYTHON 2.0
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
1. This LICENSE AGREEMENT is between BeOpen.com (``BeOpen''), having an
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
Individual or Organization (``Licensee'') accessing and otherwise
using this software in source or binary form and its associated
documentation (``the Software'').
2. Subject to the terms and conditions of this BeOpen Python License
Agreement, BeOpen hereby grants Licensee a non-exclusive,
royalty-free, world-wide license to reproduce, analyze, test, perform
and/or display publicly, prepare derivative works, distribute, and
otherwise use the Software alone or in any derivative version,
provided, however, that the BeOpen Python License is retained in the
Software, alone or in any derivative version prepared by Licensee.
3. BeOpen is making the Software available to Licensee on an ``AS IS''
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
5. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
6. This License Agreement shall be governed by and interpreted in all
respects by the law of the State of California, excluding conflict of
law provisions. Nothing in this License Agreement shall be deemed to
create any relationship of agency, partnership, or joint venture
between BeOpen and Licensee. This License Agreement does not grant
permission to use BeOpen trademarks or trade names in a trademark
sense to endorse or promote products or services of Licensee, or any
third party. As an exception, the ``BeOpen Python'' logos available
at http://www.pythonlabs.com/logos.html may be used according to the
permissions granted on that web page.
7. By copying, installing or otherwise using the software, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
CNRI OPEN SOURCE LICENSE AGREEMENT
Python 1.6 is made available subject to the terms and conditions in
CNRI's License Agreement. This Agreement together with Python 1.6 may
be located on the Internet using the following unique, persistent
identifier (known as a handle): 1895.22/1012. This Agreement may also
be obtained from a proxy server on the Internet using the following
URL: http://hdl.handle.net/1895.22/1012.
CWI PERMISSIONS STATEMENT AND DISCLAIMER
Copyright © 1991 - 1995, Stichting Mathematisch Centrum
Amsterdam, The Netherlands. All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
### Abstract:
Python is an extensible, interpreted, object-oriented programming
language. It supports a wide range of applications, from simple text
processing scripts to interactive WWW browsers.
While the Python Reference Manual (../ref/ref.html)
describes the exact syntax and semantics of the language, it does not
describe the standard library that is distributed with the language,
and which greatly enhances its immediate usability. This library
contains built-in modules (written in C) that provide access to system
functionality such as file I/O that would otherwise be inaccessible to
Python programmers, as well as modules written in Python that provide
standardized solutions for many problems that occur in everyday
programming. Some of these modules are explicitly designed to
encourage and enhance the portability of Python programs.
This library reference manual documents Python's standard library, as
well as many optional library modules (which may or may not be
available, depending on whether the underlying platform supports them
and on the configuration choices made at compile time). It also
documents the standard types of the language and its built-in
functions and exceptions, many of which are not or incompletely
documented in the Reference Manual.
This manual assumes basic knowledge about the Python language. For an
informal introduction to Python, see the
Python Tutorial (../tut/tut.html); the
Python Reference Manual (../ref/ref.html) remains the
highest authority on syntactic and semantic questions. Finally, the
manual entitled Extending and Embedding
the Python Interpreter (../ext/ext.html) describes how to add new extensions to Python
and how to embed it in other applications.


11.5.1 FTP Objects

module-ftplib.html | module-ftplib.html | module-gopherlib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.5.1 FTP Objects
Several methods are available in two flavors: one for handling text
files and another for binary files. These are named for the command
which is used followed by "lines" for the text version or
"binary" for the binary version.
FTP instances have the following methods:


11.2.4 Functions

node241.html | module-cgi.html | node243.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.2.4 Functions
These are useful if you want more control, or if you want to employ
some of the algorithms implemented in this module in other
circumstances.


Index

modindex.html | lib.html | about.html | Python Library Reference | contents.html | modindex.html
---
## Index
---
. (#letter-.) |
= (#letter-=) |
_ (#letter-_) |
a (#letter-a) |
b (#letter-b) |
c (#letter-c) |
d (#letter-d) |
e (#letter-e) |
f (#letter-f) |
g (#letter-g) |
h (#letter-h) |
i (#letter-i) |
j (#letter-j) |
k (#letter-k) |
l (#letter-l) |
m (#letter-m) |
n (#letter-n) |
o (#letter-o) |
p (#letter-p) |
q (#letter-q) |
r (#letter-r) |
s (#letter-s) |
t (#letter-t) |
u (#letter-u) |
v (#letter-v) |
w (#letter-w) |
x (#letter-x) |
y (#letter-y) |
z (#letter-z)
---
## . (dot)
---
## =
---
## _ (underscore)
---
## A
---
## B
---
## C
---
## D
---
## E
---
## F
---
## G
---
## H
---
## I
---
## J
---
## K
---
## L
---
## M
---
## N
---
## O
---
## P
---
## Q
---
## R
---
## S
---
## T
---
## U
---
## V
---
## W
---
## X
---
## Y
---
## Z


20.2.1 Registry handle objects

module--winreg.html | module--winreg.html | module-winsound.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 20.2.1 Registry handle objects
This object wraps a Windows HKEY object, automatically closing it when
the object is destroyed. To guarantee cleanup, you can call either
the Close() method on the object, or the
CloseKey() function.
All registry functions in this module return one of these objects.
All registry functions in this module which accept a handle object
also accept an integer, however, use of the handle object is
encouraged.
Handle objects provide semantics for __nonzero__() - thus
```text

if handle:
print "Yes"
```
will print `Yes` if the handle is currently valid (i.e.,
has not been closed or detached).
The object also support comparison semantics, so handle
objects will compare true if they both reference the same
underlying Windows handle value.
Handle objects can be converted to an integer (eg, using the
builtin int() function, in which case the underlying
Windows handle value is returned. You can also use the
Detach() method to return the integer handle, and
also disconnect the Windows handle from the handle object.


13.2.1 HTMLParser Objects

module-htmllib.html | module-htmllib.html | module-htmlentitydefs.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.2.1 HTMLParser Objects
In addition to tag methods, the HTMLParser class provides some
additional methods and instance variables for use within tag methods.


11.3.2 Example

node237.html | module-httplib.html | module-ftplib.html | Python Library Reference | contents.html | genindex.html
---
## 11.3.2 Example
Here is an example session:


11.4.2 Examples

node252.html | module-httplib.html | module-ftplib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.4.2 Examples
Here is an example session that uses the "GET" method:
```text

>>> import httplib
>>> h = httplib.HTTP('www.cwi.nl')
>>> h.putrequest('GET', '/index.html')
>>> h.putheader('Accept', 'text/html')
>>> h.putheader('Accept', 'text/plain')
>>> h.endheaders()
>>> errcode, errmsg, headers = h.getreply()
>>> print errcode # Should be 200
>>> f = h.getfile()
>>> data = f.read() # Get the raw HTML
>>> f.close()
```
Here is an example session that shows how to "POST" requests:


11.8.2 IMAP4 Example

imap4-objects.html | module-imaplib.html | module-nntplib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.8.2 IMAP4 Example
Here is a minimal example (without error checking) that opens a
mailbox and retrieves and prints all messages:


11.8.1 IMAP4 Objects

module-imaplib.html | module-imaplib.html | imap4-example.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 11.8.1 IMAP4 Objects
All IMAP4rev1 commands are represented by methods of the same name,
either upper-case or lower-case.
All arguments to commands are converted to strings, except for
"AUTHENTICATE", and the last argument to "APPEND" which is
passed as an IMAP4 literal. If necessary (the string contains IMAP4
protocol-sensitive characters and isn't enclosed with either
parentheses or double quotes) each string is quoted. However, the
password argument to the "LOGIN" command is always quoted.
If you want to avoid having an argument string quoted
(eg: the flags argument to "STORE") then enclose the string in
parentheses (eg: `r'(\Deleted)'`).
Each command returns a tuple: `( type , [ data ,
...])` where type is usually `'OK'` or `'NO'`,
and data is either the text from the command response, or
mandated results from the command.
An IMAP4 instance has the following methods:
The following attributes are defined on instances of IMAP4:


13.8.2 IncrementalParser Objects

xmlreader-objects.html | module-xml.sax.xmlreader.html | locator-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.8.2 IncrementalParser Objects
Instances of IncrementalParser offer the following additional
methods:


Python Library Reference

../index.html | front.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# Python Library Reference
Guido van Rossum
Fred L. Drake, Jr., editor
BeOpen PythonLabs
E-mail: python-docs@python.org
October 16, 2000
Release 2.0


13.8.4 InputSource Objects

locator-objects.html | module-xml.sax.xmlreader.html | attributes-impl-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.8.4 InputSource Objects


11. Internet Protocols and Support

profile-HotProfile.html | lib.html | module-webbrowser.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 11. Internet Protocols and Support
The modules described in this chapter implement Internet protocols and
support for related technology. They are all implemented in Python.
Most of these modules require the presence of the system-dependent
module socket (module-socket.html), which is currently
supported on most popular platforms. Here is an overview:


3.18.1 Interactive Interpreter Objects

module-code.html | module-code.html | console-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 3.18.1 Interactive Interpreter Objects


1. Introduction

contents.html | lib.html | builtin.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 1. Introduction
The ``Python library'' contains several different kinds of components.
It contains data types that would normally be considered part of the
``core'' of a language, such as numbers and lists. For these types,
the Python language core defines the form of literals and places some
constraints on their semantics, but does not fully define the
semantics. (On the other hand, the language core does define
syntactic properties like the spelling and priorities of operators.)
The library also contains built-in functions and exceptions --
objects that can be used by all Python code without the need of an
import statement. Some of these are defined by the core
language, but many are not essential for the core semantics and are
only described here.
The bulk of the library, however, consists of a collection of modules.
There are many ways to dissect this collection. Some modules are
written in C and built in to the Python interpreter; others are
written in Python and imported in source form. Some modules provide
interfaces that are highly specific to Python, like printing a stack
trace; some provide interfaces that are specific to particular
operating systems, such as access to specific hardware; others provide
interfaces that are
specific to a particular application domain, like the World-Wide Web.
Some modules are available in all versions and ports of Python; others
are only available when the underlying system supports or requires
them; yet others are available only when a particular configuration
option was chosen at the time when Python was compiled and installed.
This manual is organized ``from the inside out:'' it first describes
the built-in data types, then the built-in functions and exceptions,
and finally the modules, grouped in chapters of related modules. The
ordering of the chapters as well as the ordering of the modules within
each chapter is roughly from most relevant to least important.
This means that if you start reading this manual from the start, and
skip to the next chapter when you get bored, you will get a reasonable
overview of the available modules and application areas that are
supported by the Python library. Of course, you don't have to
read it like a novel -- you can also browse the table of contents (in
front of the manual), or look for a specific function, module or term
in the index (in the back). And finally, if you enjoy learning about
random subjects, you choose a random page number (see module
random (module-random.html)) and read a section or two. Regardless of the
order in which you read the sections of this manual, it helps to start
with chapter 2 (builtin.html#builtin), ``Built-in Types, Exceptions and
Functions,'' as the remainder of the manual assumes familiarity with
this material.
Let the show begin!


17. Python Language Services

module-Bastion.html | lib.html | module-parser.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 17. Python Language Services
Python provides a number of modules to assist in working with the
Python language. These module support tokenizing, parsing, syntax
analysis, bytecode disassembly, and various other facilities.
These modules include:


Python Library Reference


13.8.3 Locator Objects

incremental-parser-objects.html | module-xml.sax.xmlreader.html | input-source-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 13.8.3 Locator Objects
Instances of Locator provide these methods:


7.5.1 Lock Objects

module-threading.html | module-threading.html | rlock-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 7.5.1 Lock Objects
A primitive lock is a synchronization primitive that is not owned
by a particular thread when locked. In Python, it is currently
the lowest level synchronization primitive available, implemented
directly by the thread (module-thread.html) extension module.
A primitive lock is in one of two states, ``locked'' or ``unlocked''.
It is created in the unlocked state. It has two basic methods,
acquire() and release(). When the state is
unlocked, acquire() changes the state to locked and returns
immediately. When the state is locked, acquire() blocks
until a call to release() in another thread changes it to
unlocked, then the acquire() call resets it to locked and
returns. The release() method should only be called in the
locked state; it changes the state to unlocked and returns
immediately. When more than one thread is blocked in
acquire() waiting for the state to turn to unlocked, only one
thread proceeds when a release() call resets the state to
unlocked; which one of the waiting threads proceeds is not defined,
and may vary across implementations.
All methods are executed atomically.


12.14.1 Mailbox Objects

module-mailbox.html | module-mailbox.html | module-mhlib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.14.1 Mailbox Objects
All implementations of Mailbox objects have one externally visible
method:


13. Structured Markup Processing Tools

module-robotparser.html | lib.html | module-sgmllib.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 13. Structured Markup Processing Tools
Python supports a variety of modules to work with various forms of
structured data markup. This includes modules to work with the
Standard Generalized Markup Language (SGML) and the Hypertext Markup
Language (HTML), and several interfaces for working with the
Extensible Markup Language (XML).


4.2.5 Match Objects

re-objects.html | module-re.html | module-struct.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 4.2.5 Match Objects
MatchObject instances support the following methods and attributes:


4.2.2 Matching vs. Searching

re-syntax.html | module-re.html | Contents_of_Module_re.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 4.2.2 Matching vs. Searching
Python offers two different primitive operations based on regular
expressions: match and search. If you are accustomed to Perl's
semantics, the search operation is what you're looking for. See the
search() function and corresponding method of compiled
regular expression objects.
Note that match may differ from search using a regular expression
beginning with "^": "^" matches only at the
start of the string, or in MULTILINE mode also immediately
following a newline. The ``match'' operation succeeds only if the
pattern matches at the start of the string regardless of mode, or at
the starting position given by the optional pos argument
regardless of whether a newline precedes it.
```text

re.compile("a").match("ba", 1) # succeeds
re.compile("^a").search("ba", 1) # fails; 'a' not at start
re.compile("^a").search("\na", 1) # fails; 'a' not at start
re.compile("^a", re.M).search("\na", 1) # succeeds
re.compile("^a", re.M).search("ba", 1) # fails; no preceding \n
```


12.2.1 Message Objects

module-rfc822.html | module-rfc822.html | addresslist-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.2.1 Message Objects
A Message instance has the following methods:
Message instances also support a read-only mapping interface.
In particular: `m [name]` is like
`m .getheader(name)` but raises KeyError if
there is no matching header; and `len( m )`,
`m .has_key(name)`, `m .keys()`,
`m .values()` and `m .items()` act as expected
(and consistently).
Finally, Message instances have two public instance variables:


12.15.2 Folder Objects

mh-objects.html | module-mhlib.html | mh-message-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.15.2 Folder Objects
Folder instances represent open folders and have the following
methods:


12.15.3 Message Objects

mh-folder-objects.html | module-mhlib.html | module-mimify.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.15.3 Message Objects
The Message class adds one method to those of
mimetools.Message:


12.15.1 MH Objects

module-mhlib.html | module-mhlib.html | mh-folder-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.15.1 MH Objects
MH instances have the following methods:


module-mimetools.html | module-mimetools.html | module-MimeWriter.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.3.1 Additional Methods of Message Objects
The Message class defines the following methods in
addition to the rfc822.Message methods:


module-mimetools.html | module-mimetools.html | module-MimeWriter.html | Python Library Reference | contents.html | genindex.html
---
## 12.7.1 Additional Methods of Message objects
The Message class defines the following methods in
addition to the rfc822.Message methods:


12.4.1 MimeWriter Objects

module-MimeWriter.html | module-MimeWriter.html | module-multifile.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## 12.4.1 MimeWriter Objects
MimeWriter instances have the following methods:


5. Miscellaneous Services

module-unicodedata.html | lib.html | module-math.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 5. Miscellaneous Services
The modules described in this chapter provide miscellaneous services
that are available in all Python versions. Here's an overview:


14. Multimedia Services

xml-namespace.html | lib.html | module-audioop.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 14. Multimedia Services
The modules described in this chapter implement various algorithms or
interfaces that are mainly useful for multimedia applications. They
are available at the discretion of the installation. Here's an overview:


Module Index

reporting-bugs.html | lib.html | genindex.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
## Module Index
Some module names are followed by an annotation indicating what
platform they are available on.


20.2 _winreg - Windows registry access

msvcrt-other.html | node413.html | handle-object.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 20.2 _winreg -
Windows registry access
Availability: Windows.
New in version 2.0.
These functions expose the Windows registry API to Python. Instead of
using an integer as the registry handle, a handle object is used to
ensure that the handles are closed correctly, even if the programmer
neglects to explicitly close them.
This module exposes a very low-level interface to the Windows
registry; it is expected that in the future a new `winreg`
module will be created offering a higher-level interface to the
registry API.
This module offers the following functions:


module-imageop.html | mmedia.html | module-sunau.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 14.3 aifc --
Read and write AIFF and AIFC files
This module provides support for reading and writing AIFF and AIFF-C
files. AIFF is Audio Interchange File Format, a format for storing
digital audio samples in a file. AIFF-C is a newer version of the
format that includes the ability to compress the audio data.
Caveat: Some operations may only work under IRIX; these will
raise ImportError when attempting to import the
cl module, which is only available on IRIX.
Audio files have a number of parameters that describe the audio data.
The sampling rate or frame rate is the number of times per second the
sound is sampled. The number of channels indicate if the audio is
mono, stereo, or quadro. Each frame consists of one sample per
channel. The sample size is the size in bytes of each sample. Thus a
frame consists of nchannels*samplesize bytes, and a
second's worth of audio consists of
nchannels*samplesize*framerate bytes.
For example, CD quality audio has a sample size of two bytes (16
bits), uses two channels (stereo) and has a frame rate of 44,100
frames/second. This gives a frame size of 4 bytes (2*2), and a
second's worth occupies 2*2*44100 bytes, i.e. 176,400 bytes.
Module aifc defines the following function:
Objects returned by open() when a file is opened for
reading have the following methods:
Objects returned by open() when a file is opened for
writing have all the above methods, except for readframes() and
setpos(). In addition the following methods exist. The
get*() methods can only be called after the corresponding
set*() methods have been called. Before the first
writeframes() or writeframesraw(), all parameters
except for the number of frames must be filled in.


al-port-objects.html | sgi.html | module-cd.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 18.2 AL --
Constants used with the al module
Availability: IRIX.
This module defines symbolic constants needed to use the built-in
module al (module-al.html) (see above); they are equivalent to those defined
in the C header file `<audio.h>` except that the name prefix
"AL_" is omitted. Read the module source for a complete list of
the defined names. Suggested use:


18.1 al -- Audio functions on the SGI

sgi.html | sgi.html | al-config-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
---
# 18.1 al --
Audio functions on the SGI
Availability: IRIX.
This module provides access to the audio facilities of the SGI Indy
and Indigo workstations. See section 3A of the IRIX man pages for
details. You'll need to read those man pages to understand what these
functions do! Some of the functions are not available in IRIX
releases before 4.0.5. Again, see the manual to check whether a
specific function is available on your platform.
All functions and methods defined in this module are equivalent to
the C functions with "AL" prefixed to their name.
Symbolic constants from the C header file `<audio.h>` are
defined in the standard module
AL (module-al-constants.html), see below.
Warning: the current version of the audio library may dump core
when bad argument values are passed rather than returning an error
status. Unfortunately, since the precise circumstances under which
this may happen are undocumented and hard to check, the Python
interface can provide no protection against this kind of problems.
(One example is specifying an excessive queue size -- there is no
documented upper limit.)
The module defines the following functions: