Contents

front.html | lib.html | intro.html | Python Library Reference | modindex.html | genindex.html
Previous:
Front Matter (front.html)
Up:
Python Library Reference (lib.html)
Next:
1. Introduction (intro.html)
---
## Contents
Table of Contents
- Front Matter (front.html)
  1. Introduction (intro.html)
  2. Built-In Objects (builtin.html)
  - 2.1 Built-in Functions (built-in-funcs.html)
  2.2 Built-in Types (types.html)
  - 2.2.1 Truth Value Testing (truth.html)
  2.2.2 Boolean Operations (boolean.html)
  2.2.3 Comparisons (comparisons.html)
  2.2.4 Numeric Types (typesnumeric.html)
  2.2.5 Iterator Types (typeiter.html)
  2.2.6 Sequence Types (typesseq.html)
  2.2.7 Mapping Types (typesmapping.html)
  2.2.8 File Objects (bltin-file-objects.html)
  2.2.9 Other Built-in Types (typesother.html)
  2.2.10 Special Attributes (specialattrs.html)
  2.3 Built-in Exceptions (module-exceptions.html)
  2.4 Built-in Constants (node33.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 weakref -- Weak references (module-weakref.html)
  - 3.3.1 Weak Reference Objects (weakref-objects.html)
  3.3.2 Example (weakref-example.html)
  3.3.3 Weak References in Extension Types (weakref-extension.html)
  3.4 fpectl -- Floating point exception control (module-fpectl.html)
  - 3.4.1 Example (fpectl-example.html)
  3.4.2 Limitations and other considerations (node43.html)
  3.5 atexit -- Exit handlers (module-atexit.html)
  - 3.5.1 atexit Example (atexit-example.html)
  3.6 types -- Names for built-in types (module-types.html)
  3.7 UserDict -- Class wrapper for dictionary objects (module-UserDict.html)
  3.8 UserList -- Class wrapper for list objects (module-UserList.html)
  3.9 UserString -- Class wrapper for string objects (module-UserString.html)
  3.10 operator -- Standard operators as functions. (module-operator.html)
  - 3.10.1 Mapping Operators to Functions (operator-map.html)
  3.11 inspect -- Inspect live objects (module-inspect.html)
  - 3.11.1 Types and members (inspect-types.html)
  3.11.2 Retrieving source code (inspect-source.html)
  3.11.3 Classes and functions (inspect-classes-functions.html)
  3.11.4 The interpreter stack (inspect-stack.html)
  3.12 traceback -- Print or retrieve a stack traceback (module-traceback.html)
  - 3.12.1 Traceback Example (traceback-example.html)
  3.13 linecache -- Random access to text lines (module-linecache.html)
  3.14 pickle -- Python object serialization (module-pickle.html)
  - 3.14.1 Relationship to other Python modules (node61.html)
  3.14.2 Data stream format (node62.html)
  3.14.3 Usage (node63.html)
  3.14.4 What can be pickled and unpickled? (node64.html)
  3.14.5 The pickle protocol (pickle-protocol.html)
  3.14.6 Subclassing Unpicklers (pickle-sub.html)
  3.14.7 Example (pickle-example.html)
  3.15 cPickle -- A faster pickle (module-cPickle.html)
  3.16 copy_reg -- Register pickle support functions (module-copyreg.html)
  3.17 shelve -- Python object persistence (module-shelve.html)
  - 3.17.1 Restrictions (node74.html)
  3.17.2 Example (node75.html)
  3.18 copy -- Shallow and deep copy operations (module-copy.html)
  3.19 marshal -- Internal Python object serialization (module-marshal.html)
  3.20 warnings -- Warning control (module-warnings.html)
  - 3.20.1 Warning Categories (warning-categories.html)
  3.20.2 The Warnings Filter (warning-filter.html)
  3.20.3 Available Functions (warning-functions.html)
  3.21 imp -- Access the import internals (module-imp.html)
  - 3.21.1 Examples (examples-imp.html)
  3.22 pkgutil -- Package extension utility (module-pkgutil.html)
  3.23 code -- Interpreter base classes (module-code.html)
  - 3.23.1 Interactive Interpreter Objects (interpreter-objects.html)
  3.23.2 Interactive Console Objects (console-objects.html)
  3.24 codeop -- Compile Python code (module-codeop.html)
  3.25 pprint -- Data pretty printer (module-pprint.html)
  - 3.25.1 PrettyPrinter Objects (node90.html)
  3.26 repr -- Alternate repr() implementation (module-repr.html)
  - 3.26.1 Repr Objects (Repr-objects.html)
  3.26.2 Subclassing Repr Objects (subclassing-reprs.html)
  3.27 new -- Creation of runtime internal objects (module-new.html)
  3.28 site -- Site-specific configuration hook (module-site.html)
  3.29 user -- User-specific configuration hook (module-user.html)
  3.30 __builtin__ -- Built-in functions (module-builtin.html)
  3.31 __main__ -- Top-level script environment (module-main.html)
  3.32 __future__ -- Future statement definitions (module-future.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 (node105.html)
  4.2.4 Regular Expression Objects (re-objects.html)
  4.2.5 Match Objects (match-objects.html)
  4.2.6 Examples (node108.html)
  4.3 struct -- Interpret strings as packed binary data (module-struct.html)
  4.4 difflib -- Helpers for computing deltas (module-difflib.html)
  - 4.4.1 SequenceMatcher Objects (sequence-matcher.html)
  4.4.2 SequenceMatcher Examples (sequencematcher-examples.html)
  4.4.3 Differ Objects (differ-objects.html)
  4.4.4 Differ Example (differ-examples.html)
  4.5 fpformat -- Floating point conversions (module-fpformat.html)
  4.6 StringIO -- Read and write strings as files (module-StringIO.html)
  4.7 cStringIO -- Faster version of StringIO (module-cStringIO.html)
  4.8 textwrap -- Text wrapping and filling (module-textwrap.html)
  4.9 codecs -- Codec registry and base classes (module-codecs.html)
  - 4.9.1 Codec Base Classes (node120.html)
  4.9.2 Standard Encodings (node126.html)
  4.9.3 encodings.idna -- Internationalized Domain Names in Applications (module-encodings.idna.html)
  4.10 unicodedata -- Unicode Database (module-unicodedata.html)
  4.11 stringprep -- Internet String Preparation (module-stringprep.html)
  5. Miscellaneous Services (misc.html)
  - 5.1 pydoc -- Documentation generator and online help system (module-pydoc.html)
  5.2 doctest -- Test docstrings represent reality (module-doctest.html)
  - 5.2.1 Normal Usage (node133.html)
  5.2.2 Which Docstrings Are Examined? (node134.html)
  5.2.3 What's the Execution Context? (node135.html)
  5.2.4 What About Exceptions? (node136.html)
  5.2.5 Advanced Usage (node137.html)
  5.2.6 How are Docstring Examples Recognized? (node138.html)
  5.2.7 Warnings (node139.html)
  5.2.8 Soapbox (node140.html)
  5.3 unittest -- Unit testing framework (module-unittest.html)
  - 5.3.1 Minimal example (minimal-example.html)
  5.3.2 Organizing test code (organizing-tests.html)
  5.3.3 Re-using old test code (legacy-unit-tests.html)
  5.3.4 Classes and functions (unittest-contents.html)
  5.3.5 TestCase Objects (testcase-objects.html)
  5.3.6 TestSuite Objects (testsuite-objects.html)
  5.3.7 TestResult Objects (testresult-objects.html)
  5.3.8 TestLoader Objects (testloader-objects.html)
  5.3.9 Getting Extended Error Information (unittest-error-info.html)
  5.4 test -- Regression tests package for Python (module-test.html)
  - 5.4.1 [test.testsupport]test.test_support -- -- Utility functions for tests (module-test.testsupport.html)
  5.4.2 Writing Unit Tests for the test package (writing-tests.html)
  5.4.3 Running tests Using regrtest.py (regrtest.html)
  5.5 math -- Mathematical functions (module-math.html)
  5.6 cmath -- Mathematical functions for complex numbers (module-cmath.html)
  5.7 random -- Generate pseudo-random numbers (module-random.html)
  5.8 whrandom -- Pseudo-random number generator (module-whrandom.html)
  5.9 bisect -- Array bisection algorithm (module-bisect.html)
  - 5.9.1 Examples (bisect-example.html)
  5.10 heapq -- Heap queue algorithm (module-heapq.html)
  - 5.10.1 Theory (node162.html)
  5.11 array -- Efficient arrays of numeric values (module-array.html)
  5.12 sets -- Unordered collections of unique elements (module-sets.html)
  - 5.12.1 Set Objects (set-objects.html)
  5.12.2 Example (set-example.html)
  5.12.3 Protocol for automatic conversion to immutable (immutable-transforms.html)
  5.13 itertools -- Functions creating iterators for efficient looping (module-itertools.html)
  - 5.13.1 Itertool functions (itertools-functions.html)
  5.13.2 Examples (itertools-example.html)
  5.14 ConfigParser -- Configuration file parser (module-ConfigParser.html)
  - 5.14.1 RawConfigParser Objects (RawConfigParser-objects.html)
  5.14.2 ConfigParser Objects (ConfigParser-objects.html)
  5.15 fileinput -- Iterate over lines from multiple input streams (module-fileinput.html)
  5.16 xreadlines -- Efficient iteration over a file (module-xreadlines.html)
  5.17 calendar -- General calendar-related functions (module-calendar.html)
  5.18 cmd -- Support for line-oriented command interpreters (module-cmd.html)
  - 5.18.1 Cmd Objects (Cmd-objects.html)
  5.19 shlex -- Simple lexical analysis (module-shlex.html)
  - 5.19.1 Module Contents (node180.html)
  5.19.2 shlex Objects (shlex-objects.html)
  5.19.3 Parsing Rules (shlex-parsing-rules.html)
  6. Generic Operating System Services (allos.html)
  - 6.1 os -- Miscellaneous operating system 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.8.2 Flow Control Issues (popen2-flow-control.html)
  6.9 datetime -- Basic date and time types (module-datetime.html)
  - 6.9.1 Available Types (node202.html)
  6.9.2 timedelta Objects (datetime-timedelta.html)
  6.9.3 date Objects (datetime-date.html)
  6.9.4 datetime Objects (datetime-datetime.html)
  6.9.5 time Objects (datetime-time.html)
  6.9.6 tzinfo Objects (datetime-tzinfo.html)
  6.9.7 strftime() Behavior (node208.html)
  6.10 time -- Time access and conversions (module-time.html)
  6.11 sched -- Event scheduler (module-sched.html)
  - 6.11.1 Scheduler Objects (scheduler-objects.html)
  6.12 mutex -- Mutual exclusion support (module-mutex.html)
  - 6.12.1 Mutex Objects (mutex-objects.html)
  6.13 getpass -- Portable password input (module-getpass.html)
  6.14 curses -- Terminal handling for character-cell displays (module-curses.html)
  - 6.14.1 Functions (curses-functions.html)
  6.14.2 Window Objects (curses-window-objects.html)
  6.14.3 Constants (node218.html)
  6.15 curses.textpad -- Text input widget for curses programs (module-curses.textpad.html)
  - 6.15.1 Textbox objects (curses-textpad-objects.html)
  6.16 curses.wrapper -- Terminal handler for curses programs (module-curses.wrapper.html)
  6.17 curses.ascii -- Utilities for ASCII characters (module-curses.ascii.html)
  6.18 curses.panel -- A panel stack extension for curses. (module-curses.panel.html)
  - 6.18.1 Functions (cursespanel-functions.html)
  6.18.2 Panel Objects (curses-panel-objects.html)
  6.19 getopt -- Parser for command line options (module-getopt.html)
  6.20 optparse -- Powerful parser for command line options. (module-optparse.html)
  - 6.20.1 Philosophy (optparse-philosophy.html)
  6.20.2 Basic Usage (optparse-basic-usage.html)
  6.20.3 Advanced Usage (optparse-advanced-usage.html)
  6.20.4 Callback Options (optparse-callback-options.html)
  6.20.5 Extending optparse (optparse-extending.html)
  6.21 tempfile -- Generate temporary files and directories (module-tempfile.html)
  6.22 errno -- Standard errno system symbols (module-errno.html)
  6.23 glob -- Unix style pathname pattern expansion (module-glob.html)
  6.24 fnmatch -- Unix filename pattern matching (module-fnmatch.html)
  6.25 shutil -- High-level file operations (module-shutil.html)
  - 6.25.1 Example (shutil-example.html)
  6.26 locale -- Internationalization services (module-locale.html)
  - 6.26.1 Background, details, hints, tips and caveats (node264.html)
  6.26.2 For extension writers and programs that embed Python (embedding-locale.html)
  6.26.3 Access to message catalogs (locale-gettext.html)
  6.27 gettext -- Multilingual internationalization services (module-gettext.html)
  - 6.27.1 GNU gettext API (node268.html)
  6.27.2 Class-based API (node269.html)
  6.27.3 Internationalizing your programs and modules (node274.html)
  6.27.4 Acknowledgements (node279.html)
  6.28 logging -- Logging facility for Python (module-logging.html)
  - 6.28.1 Logger Objects (node281.html)
  6.28.2 Handler Objects (node282.html)
  6.28.3 Formatter Objects (node293.html)
  6.28.4 Filter Objects (node294.html)
  6.28.5 LogRecord Objects (node295.html)
  6.28.6 Thread Safety (node296.html)
  6.28.7 Configuration (node297.html)
  6.28.8 Using the logging package (node300.html)
  7. Optional Operating System Services (someos.html)
  - 7.1 signal -- Set handlers for asynchronous events (module-signal.html)
  - 7.1.1 Example (node304.html)
  7.2 socket -- Low-level networking interface (module-socket.html)
  - 7.2.1 Socket Objects (socket-objects.html)
  7.2.2 SSL Objects (ssl-objects.html)
  7.2.3 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.5.7 Timer Objects (timer-objects.html)
  7.6 dummy_thread -- Drop-in replacement for the thread module (module-dummythread.html)
  7.7 dummy_threading -- Drop-in replacement for the threading module (module-dummythreading.html)
  7.8 Queue -- A synchronized queue class (module-Queue.html)
  - 7.8.1 Queue Objects (QueueObjects.html)
  7.9 mmap --
  Memory-mapped file support (module-mmap.html)
  7.10 anydbm -- Generic access to DBM-style databases (module-anydbm.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 dumbdbm -- Portable DBM implementation (module-dumbdbm.html)
  - 7.14.1 Dumbdbm Objects (dumbdbm-objects.html)
  7.15 zlib -- Compression compatible with gzip (module-zlib.html)
  7.16 gzip -- Support for gzip files (module-gzip.html)
  7.17 bz2 -- Compression compatible with bzip2 (module-bz2.html)
  - 7.17.1 (De)compression of files (node337.html)
  7.17.2 Sequential (de)compression (node338.html)
  7.17.3 One-shot (de)compression (node339.html)
  7.18 zipfile -- Work with ZIP archives (module-zipfile.html)
  - 7.18.1 ZipFile Objects (zipfile-objects.html)
  7.18.2 PyZipFile Objects (pyzipfile-objects.html)
  7.18.3 ZipInfo Objects (zipinfo-objects.html)
  7.19 tarfile -- Read and write tar archive files (module-tarfile.html)
  - 7.19.1 TarFile Objects (tarfile-objects.html)
  7.19.2 TarInfo Objects (tarinfo-objects.html)
  7.19.3 Examples (tar-examples.html)
  7.20 readline -- GNU readline interface (module-readline.html)
  - 7.20.1 Example (readline-example.html)
  7.21 rlcompleter -- Completion function for GNU readline (module-rlcompleter.html)
  - 7.21.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 (node364.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 (node373.html)
  8.15.2 Resource Usage (node374.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 (debugger-hooks.html)
  10. The Python Profiler (profile.html)
  - 10.1 Introduction to the profiler (node382.html)
  10.2 How Is This Profiler Different From The Old Profiler? (node383.html)
  10.3 Instant Users Manual (profile-instant.html)
  10.4 What Is Deterministic Profiling? (node385.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 (node390.html)
  10.9 hotshot -- High performance logging profiler (module-hotshot.html)
  - 10.9.1 Profile Objects (hotshot-objects.html)
  10.9.2 Using hotshot data (module-hotshot.stats.html)
  10.9.3 Example Usage (hotshot-example.html)
  10.10 timeit -- Measure execution time of small code snippets (module-timeit.html)
  - 10.10.1 Command Line Interface (node396.html)
  10.10.2 Examples (node397.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 (node403.html)
  11.2.3 Higher Level Interface (node404.html)
  11.2.4 Old classes (node405.html)
  11.2.5 Functions (node406.html)
  11.2.6 Caring about security (cgi-security.html)
  11.2.7 Installing your CGI script on a Unix system (node408.html)
  11.2.8 Testing your CGI script (node409.html)
  11.2.9 Debugging CGI scripts (node410.html)
  11.2.10 Common problems and solutions (node411.html)
  11.3 cgitb -- Traceback manager for CGI scripts (module-cgitb.html)
  11.4 urllib -- Open arbitrary resources by URL (module-urllib.html)
  - 11.4.1 URLopener Objects (urlopener-objs.html)
  11.4.2 Examples (node415.html)
  11.5 urllib2 -- extensible library for opening URLs (module-urllib2.html)
  - 11.5.1 Request Objects (request-objects.html)
  11.5.2 OpenerDirector Objects (opener-director-objects.html)
  11.5.3 BaseHandler Objects (base-handler-objects.html)
  11.5.4 HTTPRedirectHandler Objects (http-redirect-handler.html)
  11.5.5 ProxyHandler Objects (proxy-handler.html)
  11.5.6 HTTPPasswordMgr Objects (http-password-mgr.html)
  11.5.7 AbstractBasicAuthHandler Objects (abstract-basic-auth-handler.html)
  11.5.8 HTTPBasicAuthHandler Objects (http-basic-auth-handler.html)
  11.5.9 ProxyBasicAuthHandler Objects (proxy-basic-auth-handler.html)
  11.5.10 AbstractDigestAuthHandler Objects (abstract-digest-auth-handler.html)
  11.5.11 HTTPDigestAuthHandler Objects (http-digest-auth-handler.html)
  11.5.12 ProxyDigestAuthHandler Objects (proxy-digest-auth-handler.html)
  11.5.13 HTTPHandler Objects (http-handler-objects.html)
  11.5.14 HTTPSHandler Objects (https-handler-objects.html)
  11.5.15 FileHandler Objects (file-handler-objects.html)
  11.5.16 FTPHandler Objects (ftp-handler-objects.html)
  11.5.17 CacheFTPHandler Objects (cacheftp-handler-objects.html)
  11.5.18 GopherHandler Objects (gopher-handler.html)
  11.5.19 UnknownHandler Objects (unknown-handler-objects.html)
  11.5.20 Examples (urllib2-examples.html)
  11.6 httplib -- HTTP protocol client (module-httplib.html)
  - 11.6.1 HTTPConnection Objects (httpconnection-objects.html)
  11.6.2 HTTPResponse Objects (httpresponse-objects.html)
  11.6.3 Examples (httplib-examples.html)
  11.7 ftplib -- FTP protocol client (module-ftplib.html)
  - 11.7.1 FTP Objects (ftp-objects.html)
  11.8 gopherlib -- Gopher protocol client (module-gopherlib.html)
  11.9 poplib -- POP3 protocol client (module-poplib.html)
  - 11.9.1 POP3 Objects (pop3-objects.html)
  11.9.2 POP3 Example (pop3-example.html)
  11.10 imaplib -- IMAP4 protocol client (module-imaplib.html)
  - 11.10.1 IMAP4 Objects (imap4-objects.html)
  11.10.2 IMAP4 Example (imap4-example.html)
  11.11 nntplib -- NNTP protocol client (module-nntplib.html)
  - 11.11.1 NNTP Objects (nntp-objects.html)
  11.12 smtplib -- SMTP protocol client (module-smtplib.html)
  - 11.12.1 SMTP Objects (SMTP-objects.html)
  11.12.2 SMTP Example (SMTP-example.html)
  11.13 telnetlib -- Telnet client (module-telnetlib.html)
  - 11.13.1 Telnet Objects (telnet-objects.html)
  11.13.2 Telnet Example (telnet-example.html)
  11.14 urlparse -- Parse URLs into components (module-urlparse.html)
  11.15 SocketServer -- A framework for network servers (module-SocketServer.html)
  11.16 BaseHTTPServer -- Basic HTTP server (module-BaseHTTPServer.html)
  11.17 SimpleHTTPServer -- Simple HTTP request handler (module-SimpleHTTPServer.html)
  11.18 CGIHTTPServer -- CGI-capable HTTP request handler (module-CGIHTTPServer.html)
  11.19 Cookie -- HTTP state management (module-Cookie.html)
  - 11.19.1 Cookie Objects (cookie-objects.html)
  11.19.2 Morsel Objects (morsel-objects.html)
  11.19.3 Example (cookie-example.html)
  11.20 xmlrpclib -- XML-RPC client access (module-xmlrpclib.html)
  - 11.20.1 ServerProxy Objects (serverproxy-objects.html)
  11.20.2 Boolean Objects (boolean-objects.html)
  11.20.3 DateTime Objects (datetime-objects.html)
  11.20.4 Binary Objects (binary-objects.html)
  11.20.5 Fault Objects (fault-objects.html)
  11.20.6 ProtocolError Objects (protocol-error-objects.html)
  11.20.7 Convenience Functions (node474.html)
  11.20.8 Example of Client Usage (xmlrpc-client-example.html)
  11.21 SimpleXMLRPCServer -- Basic XML-RPC server (module-SimpleXMLRPCServer.html)
  - 11.21.1 SimpleXMLRPCServer Objects (simple-xmlrpc-servers.html)
  11.21.2 CGIXMLRPCRequestHandler (node478.html)
  11.22 DocXMLRPCServer -- Self-documenting XML-RPC server (module-DocXMLRPCServer.html)
  - 11.22.1 DocXMLRPCServer Objects (doc-xmlrpc-servers.html)
  11.22.2 DocCGIXMLRPCRequestHandler (node481.html)
  11.23 asyncore -- Asynchronous socket handler (module-asyncore.html)
  - 11.23.1 asyncore Example basic HTTP client (asyncore-example.html)
  11.24 asynchat -- Asynchronous socket command/response handler (module-asynchat.html)
  - 11.24.1 asynchat - Auxiliary Classes and Functions (node485.html)
  11.24.2 asynchat Example (asynchat-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 email -- An email and MIME handling package (module-email.html)
  - 12.2.1 Representing an email message (module-email.Message.html)
  12.2.2 Parsing email messages (module-email.Parser.html)
  12.2.3 Generating MIME documents (module-email.Generator.html)
  12.2.4 Creating email and MIME objects from scratch (node501.html)
  12.2.5 Internationalized headers (module-email.Header.html)
  12.2.6 Representing character sets (module-email.Charset.html)
  12.2.7 Encoders (module-email.Encoders.html)
  12.2.8 Exception classes (module-email.Errors.html)
  12.2.9 Miscellaneous utilities (module-email.Utils.html)
  12.2.10 Iterators (module-email.Iterators.html)
  12.2.11 Differences from email v1 (up to Python 2.2.1) (node508.html)
  12.2.12 Differences from mimelib (node509.html)
  12.2.13 Examples (node510.html)
  12.3 mailcap -- Mailcap file handling. (module-mailcap.html)
  12.4 mailbox -- Read various mailbox formats (module-mailbox.html)
  - 12.4.1 Mailbox Objects (mailbox-objects.html)
  12.5 mhlib -- Access to MH mailboxes (module-mhlib.html)
  - 12.5.1 MH Objects (mh-objects.html)
  12.5.2 Folder Objects (mh-folder-objects.html)
  12.5.3 Message Objects (mh-message-objects.html)
  12.6 mimetools -- Tools for parsing MIME messages (module-mimetools.html)
  - 12.6.1 Additional Methods of Message Objects (mimetools-message-objects.html)
  12.7 mimetypes -- Map filenames to MIME types (module-mimetypes.html)
  - 12.7.1 MimeTypes Objects (mimetypes-objects.html)
  12.8 MimeWriter -- Generic MIME file writer (module-MimeWriter.html)
  - 12.8.1 MimeWriter Objects (MimeWriter-objects.html)
  12.9 mimify -- MIME processing of mail messages (module-mimify.html)
  12.10 multifile -- Support for files containing distinct parts (module-multifile.html)
  - 12.10.1 MultiFile Objects (MultiFile-objects.html)
  12.10.2 MultiFile Example (multifile-example.html)
  12.11 rfc822 -- Parse RFC 2822 mail headers (module-rfc822.html)
  - 12.11.1 Message Objects (message-objects.html)
  12.11.2 AddressList Objects (addresslist-objects.html)
  12.12 base64 -- Encode and decode MIME base64 data (module-base64.html)
  12.13 binascii -- Convert between binary and ASCII (module-binascii.html)
  12.14 binhex -- Encode and decode binhex4 files (module-binhex.html)
  - 12.14.1 Notes (binhex-notes.html)
  12.15 quopri -- Encode and decode MIME quoted-printable data (module-quopri.html)
  12.16 uu -- Encode and decode uuencode files (module-uu.html)
  12.17 xdrlib -- Encode and decode XDR data (module-xdrlib.html)
  - 12.17.1 Packer Objects (xdr-packer-objects.html)
  12.17.2 Unpacker Objects (xdr-unpacker-objects.html)
  12.17.3 Exceptions (xdr-exceptions.html)
  12.18 netrc -- netrc file processing (module-netrc.html)
  - 12.18.1 netrc Objects (netrc-objects.html)
  12.19 robotparser -- Parser for robots.txt (module-robotparser.html)
  12.20 csv -- CSV File Reading and Writing (module-csv.html)
  - 12.20.1 Module Contents (node545.html)
  12.20.2 Dialects and Formatting Parameters (csv-fmt-params.html)
  12.20.3 Reader Objects (node547.html)
  12.20.4 Writer Objects (node548.html)
  12.20.5 Examples (node549.html)
  13. Structured Markup Processing Tools (markup.html)
  - 13.1 HTMLParser -- Simple HTML and XHTML parser (module-HTMLParser.html)
  - 13.1.1 Example HTML Parser Application (htmlparser-example.html)
  13.2 sgmllib -- Simple SGML parser (module-sgmllib.html)
  13.3 htmllib -- A parser for HTML documents (module-htmllib.html)
  - 13.3.1 HTMLParser Objects (html-parser-objects.html)
  13.4 htmlentitydefs -- Definitions of HTML general entities (module-htmlentitydefs.html)
  13.5 xml.parsers.expat -- Fast XML parsing using Expat (module-xml.parsers.expat.html)
  - 13.5.1 XMLParser Objects (xmlparser-objects.html)
  13.5.2 ExpatError Exceptions (expaterror-objects.html)
  13.5.3 Example (expat-example.html)
  13.5.4 Content Model Descriptions (expat-content-models.html)
  13.5.5 Expat error constants (expat-errors.html)
  13.6 xml.dom -- The Document Object Model API (module-xml.dom.html)
  - 13.6.1 Module Contents (node564.html)
  13.6.2 Objects in the DOM (node565.html)
  13.6.3 Conformance (dom-conformance.html)
  13.7 xml.dom.minidom -- Lightweight DOM implementation (module-xml.dom.minidom.html)
  - 13.7.1 DOM Objects (dom-objects.html)
  13.7.2 DOM Example (dom-example.html)
  13.7.3 minidom and the DOM standard (minidom-and-dom.html)
  13.8 xml.dom.pulldom -- Support for building partial DOM trees (module-xml.dom.pulldom.html)
  - 13.8.1 DOMEventStream Objects (domeventstream-objects.html)
  13.9 xml.sax -- Support for SAX2 parsers (module-xml.sax.html)
  - 13.9.1 SAXException Objects (sax-exception-objects.html)
  13.10 xml.sax.handler -- Base classes for SAX handlers (module-xml.sax.handler.html)
  - 13.10.1 ContentHandler Objects (content-handler-objects.html)
  13.10.2 DTDHandler Objects (dtd-handler-objects.html)
  13.10.3 EntityResolver Objects (entity-resolver-objects.html)
  13.10.4 ErrorHandler Objects (sax-error-handler.html)
  13.11 xml.sax.saxutils -- SAX Utilities (module-xml.sax.saxutils.html)
  13.12 xml.sax.xmlreader -- Interface for XML parsers (module-xml.sax.xmlreader.html)
  - 13.12.1 XMLReader Objects (xmlreader-objects.html)
  13.12.2 IncrementalParser Objects (incremental-parser-objects.html)
  13.12.3 Locator Objects (locator-objects.html)
  13.12.4 InputSource Objects (input-source-objects.html)
  13.12.5 The Attributes Interface (attributes-objects.html)
  13.12.6 The AttributesNS Interface (attributes-ns-objects.html)
  13.13 xmllib -- A parser for XML documents (module-xmllib.html)
  - 13.13.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)
  14.11 ossaudiodev -- Access to OSS-compatible audio devices (module-ossaudiodev.html)
  - 14.11.1 Audio Device Objects (ossaudio-device-objects.html)
  14.11.2 Mixer Device Objects (mixer-device-objects.html)
  15. Cryptographic Services (crypto.html)
  - 15.1 hmac -- Keyed-Hashing for Message Authentication (module-hmac.html)
  15.2 md5 -- MD5 message digest algorithm (module-md5.html)
  15.3 sha -- SHA message digest algorithm (module-sha.html)
  15.4 mpz -- GNU arbitrary magnitude integers (module-mpz.html)
  15.5 rotor -- Enigma-like encryption and decryption (module-rotor.html)
  16. Graphical User Interfaces with Tk (tkinter.html)
  - 16.1 Tkinter -- Python interface to Tcl/Tk (module-Tkinter.html)
  - 16.1.1 Tkinter Modules (node630.html)
  16.1.2 Tkinter Life Preserver (node631.html)
  16.1.3 A (Very) Quick Look at Tcl/Tk (node634.html)
  16.1.4 Mapping Basic Tk into Tkinter (tkinter-basic-mapping.html)
  16.1.5 How Tk and Tkinter are Related (node636.html)
  16.1.6 Handy Reference (node637.html)
  16.2 Tix -- Extension widgets for Tk (module-Tix.html)
  - 16.2.1 Using Tix (node648.html)
  16.2.2 Tix Widgets (node649.html)
  16.2.3 Tix Commands (node658.html)
  16.3 ScrolledText -- Scrolled Text Widget (module-ScrolledText.html)
  16.4 turtle -- Turtle graphics for Tk (module-turtle.html)
  - 16.4.1 Pen and RawPen Objects (pen-rawpen-objects.html)
  16.5 Idle (idle.html)
  - 16.5.1 Menus (node663.html)
  16.5.2 Basic editing and navigation (node668.html)
  16.5.3 Syntax colors (node671.html)
  16.6 Other Graphical User Interface Packages (other-gui-packages.html)
  17. Restricted Execution (restricted.html)
  - 17.1 rexec -- Restricted execution framework (module-rexec.html)
  - 17.1.1 RExec Objects (rexec-objects.html)
  17.1.2 Defining restricted environments (rexec-extension.html)
  17.1.3 An example (node678.html)
  17.2 Bastion -- Restricting access to objects (module-Bastion.html)
  18. Python Language Services (language.html)
  - 18.1 parser -- Access Python parse trees (module-parser.html)
  - 18.1.1 Creating AST Objects (node682.html)
  18.1.2 Converting AST Objects (node683.html)
  18.1.3 Queries on AST Objects (node684.html)
  18.1.4 Exceptions and Error Handling (node685.html)
  18.1.5 AST Objects (node686.html)
  18.1.6 Examples (node687.html)
  18.2 symbol -- Constants used with Python parse trees (module-symbol.html)
  18.3 token -- Constants used with Python parse trees (module-token.html)
  18.4 keyword -- Testing for Python keywords (module-keyword.html)
  18.5 tokenize -- Tokenizer for Python source (module-tokenize.html)
  18.6 tabnanny -- Detection of ambiguous indentation (module-tabnanny.html)
  18.7 pyclbr -- Python class browser support (module-pyclbr.html)
  - 18.7.1 Class Descriptor Objects (pyclbr-class-objects.html)
  18.8 py_compile -- Compile Python source files (module-pycompile.html)
  18.9 compileall -- Byte-compile Python libraries (module-compileall.html)
  18.10 dis -- Disassembler for Python byte code (module-dis.html)
  - 18.10.1 Python Byte Code Instructions (bytecodes.html)
  18.11 distutils -- Building and installing Python modules (module-distutils.html)
  19. Python compiler package (compiler.html)
  - 19.1 The basic interface (module-compiler.html)
  19.2 Limitations (node704.html)
  19.3 Python Abstract Syntax (node705.html)
  - 19.3.1 AST Nodes (module-compiler.ast.html)
  19.3.2 Assignment nodes (node707.html)
  19.3.3 Examples (node708.html)
  19.4 Using Visitors to Walk ASTs (module-compiler.visitor.html)
  19.5 Bytecode Generation (node710.html)
  20. SGI IRIX Specific Services (sgi.html)
  - 20.1 al -- Audio functions on the SGI (module-al.html)
  - 20.1.1 Configuration Objects (al-config-objects.html)
  20.1.2 Port Objects (al-port-objects.html)
  20.2 AL -- Constants used with the al module (module-al-constants.html)
  20.3 cd -- CD-ROM access on SGI systems (module-cd.html)
  - 20.3.1 Player Objects (player-objects.html)
  20.3.2 Parser Objects (cd-parser-objects.html)
  20.4 fl -- FORMS library for graphical user interfaces (module-fl.html)
  - 20.4.1 Functions Defined in Module fl (node720.html)
  20.4.2 Form Objects (form-objects.html)
  20.4.3 FORMS Objects (forms-objects.html)
  20.5 FL -- Constants used with the fl module (module-fl-constants.html)
  20.6 flp -- Functions for loading stored FORMS designs (module-flp.html)
  20.7 fm -- Font Manager interface (module-fm.html)
  20.8 gl -- Graphics Library interface (module-gl.html)
  20.9 DEVICE -- Constants used with the gl module (module-DEVICE.html)
  20.10 GL -- Constants used with the gl module (module-gl-constants.html)
  20.11 imgfile -- Support for SGI imglib files (module-imgfile.html)
  20.12 jpeg -- Read and write JPEG files (module-jpeg.html)
  21. SunOS Specific Services (sunos.html)
  - 21.1 sunaudiodev -- Access to Sun audio hardware (module-sunaudiodev.html)
  - 21.1.1 Audio Device Objects (audio-device-objects.html)
  21.2 SUNAUDIODEV -- Constants used with sunaudiodev (module-sunaudiodev-constants.html)
  22. MS Windows Specific Services (node735.html)
  - 22.1 msvcrt - Useful routines from the MS VC++ runtime (module-msvcrt.html)
  - 22.1.1 File Operations (msvcrt-files.html)
  22.1.2 Console I/O (msvcrt-console.html)
  22.1.3 Other Functions (msvcrt-other.html)
  22.2 _winreg - Windows registry access (module--winreg.html)
  - 22.2.1 Registry Handle Objects (handle-object.html)
  22.3 winsound -- Sound-playing interface for Windows (module-winsound.html)
  A. Undocumented Modules (undoc.html)
  - A.1 Frameworks (node744.html)
  A.2 Miscellaneous useful utilities (node745.html)
  A.3 Platform specific modules (node746.html)
  A.4 Multimedia (node747.html)
  A.5 Obsolete (obsolete-modules.html)
  A.6 SGI-specific Extension modules (node749.html)
  B. Reporting Bugs (reporting-bugs.html)
  C. History and License (node751.html)
  - C.1 History of the software (node752.html)
  C.2 Terms and conditions for accessing or otherwise using Python (node753.html)
  Module Index (modindex.html)
  About this document ... (about.html)
End of Table of Contents


11.19.3 Example

morsel-objects.html | module-Cookie.html | module-xmlrpclib.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.19.2 Morsel Objects (morsel-objects.html)
Up:
11.19 Cookie (module-Cookie.html)
Next:
11.20 xmlrpclib (module-xmlrpclib.html)
---
## 11.19.3 Example
The following example demonstrates how to use the Cookie module.


11.19.1 Cookie Objects

module-Cookie.html | module-Cookie.html | morsel-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.19 Cookie (module-Cookie.html)
Up:
11.19 Cookie (module-Cookie.html)
Next:
11.19.2 Morsel Objects (morsel-objects.html)
---
## 11.19.1 Cookie Objects


15. Cryptographic Services

mixer-device-objects.html | lib.html | module-hmac.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
14.11.2 Mixer Device Objects (mixer-device-objects.html)
Up:
Python Library Reference (lib.html)
Next:
15.1 hmac (module-hmac.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:
hmac (module-hmac.html) | Keyed-Hashing for Message Authentication (HMAC)
implementation for Python.
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.


node545.html | module-csv.html | node547.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
12.20.1 Module Contents (node545.html)
Up:
12.20 csv (module-csv.html)
Next:
12.20.3 Reader Objects (node547.html)
---
## 12.20.2 Dialects and Formatting Parameters
To make it easier to specify the format of input and output records,
specific formatting parameters are grouped together into dialects. A
dialect is a subclass of the Dialect class having a set of specific
methods and a single validate() method. When creating reader
or writer objects, the programmer can specify a string or a subclass
of the Dialect class as the dialect parameter. In addition to, or
instead of, the dialect parameter, the programmer can also specify
individual formatting parameters, which have the same names as the
attributes defined above for the Dialect class.
Dialects support the following attributes:


6.14.1 Functions

module-curses.html | module-curses.html | curses-window-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.14 curses (module-curses.html)
Up:
6.14 curses (module-curses.html)
Next:
6.14.2 Window Objects (curses-window-objects.html)
---
## 6.14.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.18.2 Panel Objects

cursespanel-functions.html | module-curses.panel.html | module-getopt.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.18.1 Functions (cursespanel-functions.html)
Up:
6.18 curses.panel (module-curses.panel.html)
Next:
6.19 getopt (module-getopt.html)
---
## 6.18.2 Panel Objects
Panel objects, as returned by new_panel() above, are windows
with a stacking order. There's always a window associated with a
panel which determines the content, while the panel methods are
responsible for the window's depth in the panel stack.
Panel objects have the following methods:


6.15.1 Textbox objects

module-curses.textpad.html | module-curses.textpad.html | module-curses.wrapper.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.15 curses.textpad (module-curses.textpad.html)
Up:
6.15 curses.textpad (module-curses.textpad.html)
Next:
6.16 curses.wrapper (module-curses.wrapper.html)
---
## 6.15.1 Textbox objects
You can instantiate a Textbox object as follows:
Textbox objects have the following methods:


6.14.2 Window Objects

curses-functions.html | module-curses.html | node218.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.14.1 Functions (curses-functions.html)
Up:
6.14 curses (module-curses.html)
Next:
6.14.3 Constants (node218.html)
---
## 6.14.2 Window Objects
Window objects, as returned by initscr() and
newwin() above, have the
following methods:


6.18.1 Functions

module-curses.panel.html | module-curses.panel.html | curses-panel-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.18 curses.panel (module-curses.panel.html)
Up:
6.18 curses.panel (module-curses.panel.html)
Next:
6.18.2 Panel Objects (curses-panel-objects.html)
---
## 6.18.1 Functions
The module curses.panel defines the following functions:


6.9.3 date Objects

datetime-timedelta.html | module-datetime.html | datetime-datetime.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.9.2 timedelta Objects (datetime-timedelta.html)
Up:
6.9 datetime (module-datetime.html)
Next:
6.9.4 datetime Objects (datetime-datetime.html)
---
## 6.9.3 date Objects
A date object represents a date (year, month and day) in an idealized
calendar, the current Gregorian calendar indefinitely extended in both
directions. January 1 of year 1 is called day number 1, January 2 of year
1 is called day number 2, and so on. This matches the definition of the
"proleptic Gregorian" calendar in Dershowitz and Reingold's book
Calendrical Calculations, where it's the base calendar for all
computations. See the book for algorithms for converting between
proleptic Gregorian ordinals and many other calendar systems.
Other constructors, all class methods:
Class attributes:
Instance attributes (read-only):
Supported operations:
Notes:
(1): date2 is moved forward in time if `timedelta .days
> 0`, or backward if `timedelta .days < 0`. Afterward
`date2 - date1 == timedelta .days`.
`timedelta .seconds` and
`timedelta .microseconds` are ignored.
OverflowError is raised if `date2 .year`
would be smaller than MINYEAR or larger than
MAXYEAR.
(2): This isn't quite equivalent to date1 +
(-timedelta), because -timedelta in isolation can overflow in cases
where date1 - timedelta does not. `timedelta .seconds`
and `timedelta .microseconds` are ignored.
(3): This is exact, and cannot overflow. timedelta.seconds and
timedelta.microseconds are 0, and date2 + timedelta == date1
after.
(4): In other words, `date1 < date2`
if and only if `date1 .toordinal() < date2 .toordinal()`.
In order to stop comparison from falling back to the default
scheme of comparing object addresses, date comparison
normally raises TypeError if the other comparand
isn't also a date object. However, `NotImplemented`
is returned instead if the other comparand has a
timetuple attribute. This hook gives other kinds of
date objects a chance at implementing mixed-type comparison.
If not, when a date object is
compared to an object of a different type, TypeError is
raised unless the comparison is `==` or `!=`. The latter
cases return False or True, respectively.
Dates can be used as dictionary keys. In Boolean contexts, all
date objects are considered to be true.
Instance methods:


6.9.4 datetime Objects

datetime-date.html | module-datetime.html | datetime-time.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.9.3 date Objects (datetime-date.html)
Up:
6.9 datetime (module-datetime.html)
Next:
6.9.5 time Objects (datetime-time.html)
---
## 6.9.4 datetime Objects
A datetime object is a single object containing all the
information from a date object and a time object. Like a
date object, datetime assumes the current Gregorian
calendar extended in both directions; like a time object,
datetime assumes there are exactly 3600*24 seconds in every
day.
Constructor:
Other constructors, all class methods:
Class attributes:
Instance attributes (read-only):
Supported operations:
(1): datetime2 is a duration of timedelta removed from datetime1, moving
forward in time if `timedelta .days` > 0, or backward if
`timedelta .days` < 0. The result has the same tzinfo member
as the input datetime, and datetime2 - datetime1 == timedelta after.
OverflowError is raised if datetime2.year would be
smaller than MINYEAR or larger than MAXYEAR.
Note that no time zone adjustments are done even if the input is an
aware object.
(2): Computes the datetime2 such that datetime2 + timedelta == datetime1.
As for addition, the result has the same tzinfo member
as the input datetime, and no time zone adjustments are done even
if the input is aware.
This isn't quite equivalent to datetime1 + (-timedelta), because
-timedelta in isolation can overflow in cases where
datetime1 - timedelta does not.
(3): Subtraction of a datetime from a
datetime is defined only if both
operands are naive, or if both are aware. If one is aware and the
other is naive, TypeError is raised.
If both are naive, or both are aware and have the same tzinfo
member, the tzinfo members are ignored, and the result is
a timedelta object t such that
`datetime2 + t == datetime1`. No time zone
adjustments are done in this case.
If both are aware and have different tzinfo members,
`a-b` acts as if a and b were first converted to
naive UTC datetimes first. The result is
`( a .replace(tzinfo=None) - a .utcoffset()) -
( b .replace(tzinfo=None) - b .utcoffset())`
except that the implementation never overflows.
(4): datetime1 is considered less than datetime2
when datetime1 precedes datetime2 in time.
If one comparand is naive and
the other is aware, TypeError is raised. If both
comparands are aware, and have the same tzinfo member,
the common tzinfo member is ignored and the base datetimes
are compared. If both comparands are aware and have different
tzinfo members, the comparands are first adjusted by
subtracting their UTC offsets (obtained from `self.utcoffset()`).
Note:
In order to stop comparison from falling back to the default
scheme of comparing object addresses, datetime comparison
normally raises TypeError if the other comparand
isn't also a datetime object. However,
`NotImplemented` is returned instead if the other comparand
has a timetuple attribute. This hook gives other
kinds of date objects a chance at implementing mixed-type
comparison. If not, when a datetime object is
compared to an object of a different type, TypeError
is raised unless the comparison is `==` or `!=`. The
latter cases return False or True,
respectively.
datetime objects can be used as dictionary keys. In Boolean
contexts, all datetime objects are considered to be true.
Instance methods:


11.20.3 DateTime Objects

boolean-objects.html | module-xmlrpclib.html | binary-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.20.2 Boolean Objects (boolean-objects.html)
Up:
11.20 xmlrpclib (module-xmlrpclib.html)
Next:
11.20.4 Binary Objects (binary-objects.html)
---
## 11.20.3 DateTime Objects
This class may initialized from date in seconds since the epoch, a
time tuple, or an ISO 8601 time/date string. It has the following
methods, supported mainly for internal use by the
marshalling/unmarshalling code:
It also supports certain of Python's built-in operators through
_cmp__ and __repr__ methods.


6.9.5 time Objects

datetime-datetime.html | module-datetime.html | datetime-tzinfo.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.9.4 datetime Objects (datetime-datetime.html)
Up:
6.9 datetime (module-datetime.html)
Next:
6.9.6 tzinfo Objects (datetime-tzinfo.html)
---
## 6.9.5 time Objects
A time object represents a (local) time of day, independent of any
particular day, and subject to adjustment via a tzinfo object.
Class attributes:
Instance attributes (read-only):
Supported operations:
- comparison of time to time,
where a is considered less than b when a precedes
b in time. If one comparand is naive and the other is aware,
TypeError is raised. If both comparands are aware, and
have the same tzinfo member, the common tzinfo
member is ignored and the base times are compared. If both
comparands are aware and have different tzinfo members,
the comparands are first adjusted by subtracting their UTC offsets
(obtained from `self.utcoffset()`).
In order to stop mixed-type comparisons from falling back to the
default comparison by object address, when a time object is
compared to an object of a different type, TypeError is
raised unless the comparison is `==` or `!=`. The latter
cases return False or True, respectively.
- hash, use as dict key
- efficient pickling
- in Boolean contexts, a time object is considered to be
true if and only if, after converting it to minutes and
subtracting utcoffset() (or `0` if that's
`None`), the result is non-zero.
Instance methods:


6.9.2 timedelta Objects

node202.html | module-datetime.html | datetime-date.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.9.1 Available Types (node202.html)
Up:
6.9 datetime (module-datetime.html)
Next:
6.9.3 date Objects (datetime-date.html)
---
## 6.9.2 timedelta Objects
A timedelta object represents a duration, the difference
between two dates or times.
Class attributes are:
Note that, because of normalization, `timedelta.max` >
`-timedelta.min`. `-timedelta.max` is not representable as
a timedelta object.
Instance attributes (read-only):
Supported operations:
Notes:
(1): This is exact, but may overflow.
(2): This is exact, and cannot overflow.
(3): Division by 0 raises ZeroDivisionError.
(4): -timedelta.max is not representable as a timedelta object.
In addition to the operations listed above timedelta objects
support certain additions and subtractions with date and
datetime objects (see below).
Comparisons of timedelta objects are supported with the
timedelta object representing the smaller duration considered
to be the smaller timedelta.
In order to stop mixed-type comparisons from falling back to the
default comparison by object address, when a timedelta object is
compared to an object of a different type, TypeError is
raised unless the comparison is `==` or `!=`. The latter
cases return False or True, respectively.
timedelta objects are hashable (usable as dictionary keys),
support efficient pickling, and in Boolean contexts, a timedelta
object is considered to be true if and only if it isn't equal to
`timedelta(0)`.


6.9.6 tzinfo Objects

datetime-time.html | module-datetime.html | node208.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.9.5 time Objects (datetime-time.html)
Up:
6.9 datetime (module-datetime.html)
Next:
6.9.7 strftime() Behavior (node208.html)
---
## 6.9.6 tzinfo Objects
tzinfo is an abstract base clase, meaning that this class
should not be instantiated directly. You need to derive a concrete
subclass, and (at least) supply implementations of the standard
tzinfo methods needed by the datetime methods you
use. The datetime module does not supply any concrete
subclasses of tzinfo.
An instance of (a concrete subclass of) tzinfo can be passed
to the constructors for datetime and time objects.
The latter objects view their members as being in local time, and the
tzinfo object supports methods revealing offset of local time
from UTC, the name of the time zone, and DST offset, all relative to a
date or time object passed to them.
Special requirement for pickling: A tzinfo subclass must have an
__init__ method that can be called with no arguments, else it
can be pickled but possibly not unpickled again. This is a technical
requirement that may be relaxed in the future.
A concrete subclass of tzinfo may need to implement the
following methods. Exactly which methods are needed depends on the
uses made of aware datetime objects. If in doubt, simply
implement all of them.
These methods are called by a datetime or time object,
in response to their methods of the same names. A datetime
object passes itself as the argument, and a time object passes
`None` as the argument. A tzinfo subclass's methods should
therefore be prepared to accept a dt argument of `None`, or of
class datetime.
When `None` is passed, it's up to the class designer to decide the
best response. For example, returning `None` is appropriate if the
class wishes to say that time objects don't participate in the
tzinfo protocols. It may be more useful for `utcoffset(None)`
to return the standard UTC offset, as there is no other convention for
discovering the standard offset.
When a datetime object is passed in response to a
datetime method, `dt.tzinfo` is the same object as
self. tzinfo methods can rely on this, unless
user code calls tzinfo methods directly. The intent is that
the tzinfo methods interpret dt as being in local time,
and not need worry about objects in other timezones.
There is one more tzinfo method that a subclass may wish to
override:
Example tzinfo classes:
```text
from datetime import tzinfo, timedelta, datetime

ZERO = timedelta(0)
HOUR = timedelta(hours=1)

# A UTC class.

class UTC(tzinfo):
"""UTC"""

def utcoffset(self, dt):
return ZERO

def tzname(self, dt):
return "UTC"

def dst(self, dt):
return ZERO

utc = UTC()

# A class building tzinfo objects for fixed-offset time zones.
# Note that FixedOffset(0, "UTC") is a different way to build a
# UTC tzinfo object.

class FixedOffset(tzinfo):
"""Fixed offset in minutes east from UTC."""

def __init__(self, offset, name):
self.__offset = timedelta(minutes = offset)
self.__name = name

def utcoffset(self, dt):
return self.__offset

def tzname(self, dt):
return self.__name

def dst(self, dt):
return ZERO

# A class capturing the platform's idea of local time.

import time as _time

STDOFFSET = timedelta(seconds = -_time.timezone)
if _time.daylight:
DSTOFFSET = timedelta(seconds = -_time.altzone)
else:
DSTOFFSET = STDOFFSET

DSTDIFF = DSTOFFSET - STDOFFSET

class LocalTimezone(tzinfo):

def utcoffset(self, dt):
if self._isdst(dt):
return DSTOFFSET
else:
return STDOFFSET

def dst(self, dt):
if self._isdst(dt):
return DSTDIFF
else:
return ZERO

def tzname(self, dt):
return _time.tzname[self._isdst(dt)]

def _isdst(self, dt):
tt = (dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second,
dt.weekday(), 0, -1)
stamp = _time.mktime(tt)
tt = _time.localtime(stamp)
return tt.tm_isdst > 0

Local = LocalTimezone()

# A complete implementation of current DST rules for major US time zones.

def first_sunday_on_or_after(dt):
days_to_go = 6 - dt.weekday()
if days_to_go:
dt += timedelta(days_to_go)
return dt

# In the US, DST starts at 2am (standard time) on the first Sunday in April.
DSTSTART = datetime(1, 4, 1, 2)
# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct.
# which is the first Sunday on or after Oct 25.
DSTEND = datetime(1, 10, 25, 1)

class USTimeZone(tzinfo):

def __init__(self, hours, reprname, stdname, dstname):
self.stdoffset = timedelta(hours=hours)
self.reprname = reprname
self.stdname = stdname
self.dstname = dstname

def __repr__(self):
return self.reprname

def tzname(self, dt):
if self.dst(dt):
return self.dstname
else:
return self.stdname

def utcoffset(self, dt):
return self.stdoffset + self.dst(dt)

def dst(self, dt):
if dt is None or dt.tzinfo is None:
# An exception may be sensible here, in one or both cases.
# It depends on how you want to treat them. The default
# fromutc() implementation (called by the default astimezone()
# implementation) passes a datetime with dt.tzinfo is self.
return ZERO
assert dt.tzinfo is self

# Find first Sunday in April & the last in October.
start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))

# Can't compare naive to aware objects, so strip the timezone from
# dt first.
if start <= dt.replace(tzinfo=None) < end:
return HOUR
else:
return ZERO

Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
Central = USTimeZone(-6, "Central", "CST", "CDT")
Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
```
Download as text (original file name: tzinfo-examples.py). (tzinfo-examples.txt)
Note that there are unavoidable subtleties twice per year in a
tzinfo
subclass accounting for both standard and daylight time, at the DST
transition points. For concreteness, consider US Eastern (UTC -0500),
where EDT begins the minute after 1:59 (EST) on the first Sunday in
April, and ends the minute after 1:59 (EDT) on the last Sunday in October:
```text

UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM
EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM
EDT 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM

start 22:MM 23:MM 0:MM 1:MM 3:MM 4:MM

end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM
```
When DST starts (the "start" line), the local wall clock leaps from 1:59
to 3:00. A wall time of the form 2:MM doesn't really make sense on that
day, so `astimezone(Eastern)` won't deliver a result with
`hour==2` on the
day DST begins. In order for astimezone() to make this
guarantee, the rzinfo.dst() method must consider times
in the "missing hour" (2:MM for Eastern) to be in daylight time.
When DST ends (the "end" line), there's a potentially worse problem:
there's an hour that can't be spelled unambiguously in local wall time:
the last hour of daylight time. In Eastern, that's times of
the form 5:MM UTC on the day daylight time ends. The local wall clock
leaps from 1:59 (daylight time) back to 1:00 (standard time) again.
Local times of the form 1:MM are ambiguous. astimezone() mimics
the local clock's behavior by mapping two adjacent UTC hours into the
same local hour then. In the Eastern example, UTC times of the form
5:MM and 6:MM both map to 1:MM when converted to Eastern. In order for
astimezone() to make this guarantee, the tzinfo.dst()
method must consider times in the "repeated hour" to be in
standard time. This is easily arranged, as in the example, by expressing
DST switch times in the time zone's standard local time.
Applications that can't bear such ambiguities should avoid using hybrid
tzinfo subclasses; there are no ambiguities when using UTC, or
any other fixed-offset tzinfo subclass (such as a class
representing only EST (fixed offset -5 hours), or only EDT (fixed offset
-4 hours)).


7.11.1 Database Objects

module-dbhash.html | module-dbhash.html | module-whichdb.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.11 dbhash (module-dbhash.html)
Up:
7.11 dbhash (module-dbhash.html)
Next:
7.12 whichdb (module-whichdb.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 | debugger-hooks.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
9. The Python Debugger (module-pdb.html)
Up:
9. The Python Debugger (module-pdb.html)
Next:
9.2 How It Works (debugger-hooks.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.
j(ump) lineno: Set the next line that will be executed. Only available in the
bottom-most frame. This lets you jump back and execute code
again, or jump forward to skip code that you don't want to run.
It should be noted that not all jumps are allowed -- for instance it
is not possible to jump into the middle of a for loop or out
of a finally clause.
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.
pp expression: Like the "p" command, except the value of the exception is
pretty-printed using the pprint module.
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.


9.2 How It Works

debugger-commands.html | module-pdb.html | profile.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
9.1 Debugger Commands (debugger-commands.html)
Up:
9. The Python Debugger (module-pdb.html)
Next:
10. The Python Profiler (profile.html)
---
# 9.2 How It Works
Some changes were made to the interpreter:
- `sys.settrace( func )` sets the global trace function
- there can also a local trace function (see later)
Trace functions have three arguments: frame, event, and
arg. frame is the current stack frame. event is a
string: `'call'`, `'line'`, `'return'` or
`'exception'`. arg depends on the event type.
The global trace function is invoked (with event set to
`'call'`) whenever a new local scope is entered; it should return
a reference to the local trace function to be used that scope, or
`None` if the scope shouldn't be traced.
The local trace function should return a reference to itself (or to
another function for further tracing in that scope), or `None` to
turn off tracing in that scope.
Instance methods are accepted (and very useful!) as trace functions.
The events have the following meaning:
`'call'`: A function is called (or some other code block entered). The global
trace function is called; arg is `None`;
the return value specifies the local trace function.
`'line'`: The interpreter is about to execute a new line of code (sometimes
multiple line events on one line exist). The local trace function is
called; arg is `None`; the return value specifies the new
local trace function.
`'return'`: A function (or other code block) is about to return. The local trace
function is called; arg is the value that will be returned. The
trace function's return value is ignored.
`'exception'`: An exception has occurred. The local trace function is called;
arg is a triple `( exception , value , traceback )`; the return value specifies the new local trace
function.
Note that as an exception is propagated down the chain of callers, an
`'exception'` event is generated at each level.
For more information on code and frame objects, refer to the
Python Reference Manual (../ref/ref.html).


4.4.4 Differ Example

differ-objects.html | module-difflib.html | module-fpformat.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
4.4.3 Differ Objects (differ-objects.html)
Up:
4.4 difflib (module-difflib.html)
Next:
4.5 fpformat (module-fpformat.html)
---
## 4.4.4 Differ Example
This example compares two texts. First we set up the texts, sequences
of individual single-line strings ending with newlines (such sequences
can also be obtained from the readlines() method of file-like
objects):
```text

>>> text1 = ''' 1. Beautiful is better than ugly.
... 2. Explicit is better than implicit.
... 3. Simple is better than complex.
... 4. Complex is better than complicated.
... '''.splitlines(1)
>>> len(text1)
4
>>> text1[0][-1]
'\n'
>>> text2 = ''' 1. Beautiful is better than ugly.
... 3. Simple is better than complex.
... 4. Complicated is better than complex.
... 5. Flat is better than nested.
... '''.splitlines(1)
```
Next we instantiate a Differ object:
```text

>>> d = Differ()
```
Note that when instantiating a Differ object we may pass
functions to filter out line and character ``junk.'' See the
Differ() constructor for details.
Finally, we compare the two:
```text

>>> result = list(d.compare(text1, text2))
```
`result` is a list of strings, so let's pretty-print it:
```text

>>> from pprint import pprint
>>> pprint(result)
[' 1. Beautiful is better than ugly.\n',
'- 2. Explicit is better than implicit.\n',
'- 3. Simple is better than complex.\n',
'+ 3. Simple is better than complex.\n',
'? ++ \n',
'- 4. Complex is better than complicated.\n',
'? ^ ---- ^ \n',
'+ 4. Complicated is better than complex.\n',
'? ++++ ^ ^ \n',
'+ 5. Flat is better than nested.\n']
```
As a single multi-line string it looks like this:


4.4.3 Differ Objects

sequencematcher-examples.html | module-difflib.html | differ-examples.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
4.4.2 SequenceMatcher Examples (sequencematcher-examples.html)
Up:
4.4 difflib (module-difflib.html)
Next:
4.4.4 Differ Example (differ-examples.html)
---
## 4.4.3 Differ Objects
Note that Differ-generated deltas make no claim to be
minimal diffs. To the contrary, minimal diffs are often
counter-intuitive, because they synch up anywhere possible, sometimes
accidental matches 100 pages apart. Restricting synch points to
contiguous matches preserves some notion of locality, at the
occasional cost of producing a longer diff.
The Differ class has this constructor:
Differ objects are used (deltas generated) via a single
method:


6.7.1 The dircmp class

module-filecmp.html | module-filecmp.html | module-popen2.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.7 filecmp (module-filecmp.html)
Up:
6.7 filecmp (module-filecmp.html)
Next:
6.8 popen2 (module-popen2.html)
---
## 6.7.1 The dircmp class
dircmp instances are built using this constructor:
The dircmp class provides the following methods:
The dircmp offers a number of interesting attributes that may
be used to get various bits of information about the directory trees
being compared.
Note that via __getattr__() hooks, all attributes are
computed lazilly, so there is no speed penalty if only those
attributes which are lightweight to compute are used.


8.5.1 Dl Objects

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


11.22.1 DocXMLRPCServer Objects

module-DocXMLRPCServer.html | module-DocXMLRPCServer.html | node481.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.22 DocXMLRPCServer (module-DocXMLRPCServer.html)
Up:
11.22 DocXMLRPCServer (module-DocXMLRPCServer.html)
Next:
11.22.2 DocCGIXMLRPCRequestHandler (node481.html)
---
## 11.22.1 DocXMLRPCServer Objects
The DocXMLRPCServer class is derived from
SimpleXMLRPCServer.SimpleXMLRPCServer and provides a means of
creating self-documenting, stand alone XML-RPC servers. HTTP POST
requests are handled as XML-RPC method calls. HTTP GET requests are
handled by generating pydoc-style HTML documentation. This allows a
server to provide its own web-based documentation.


13.6.3.2 Accessor Methods

dom-type-mapping.html | dom-conformance.html | module-xml.dom.minidom.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.3.1 Type Mapping (dom-type-mapping.html)
Up:
13.6.3 Conformance (dom-conformance.html)
Next:
13.7 xml.dom.minidom (module-xml.dom.minidom.html)
---
### 13.6.3.2 Accessor Methods
The mapping from OMG IDL to Python defines accessor functions for IDL
attribute declarations in much the way the Java mapping
does. Mapping the IDL declarations
```text

readonly attribute string someValue;
attribute string anotherValue;
```
yields three accessor functions: a ``get'' method for
someValue (_get_someValue()), and ``get'' and
``set'' methods for
anotherValue (_get_anotherValue() and
_set_anotherValue()). The mapping, in particular, does not
require that the IDL attributes are accessible as normal Python
attributes: `object .someValue` is not required to
work, and may raise an AttributeError.
The Python DOM API, however, does require that normal attribute
access work. This means that the typical surrogates generated by
Python IDL compilers are not likely to work, and wrapper objects may
be needed on the client if the DOM objects are accessed via CORBA.
While this does require some additional consideration for CORBA DOM
clients, the implementers with experience using DOM over CORBA from
Python do not consider this a problem. Attributes that are declared
readonly may not restrict write access in all DOM
implementations.


13.6.2.7 Attr Objects

dom-element-objects.html | node565.html | dom-attributelist-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.6 Element Objects (dom-element-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.8 NamedNodeMap Objects (dom-attributelist-objects.html)
---
### 13.6.2.7 Attr Objects
Attr inherits from Node, so inherits all its
attributes.


13.6.2.8 NamedNodeMap Objects

dom-attr-objects.html | node565.html | dom-comment-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.7 Attr Objects (dom-attr-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.9 Comment Objects (dom-comment-objects.html)
---
### 13.6.2.8 NamedNodeMap Objects
NamedNodeMap does not inherit from Node.
There are also experimental methods that give this class more mapping
behavior. You can use them or you can use the standardized
getAttribute*() family of methods on the Element
objects.


13.6.2.9 Comment Objects

dom-attributelist-objects.html | node565.html | dom-text-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.8 NamedNodeMap Objects (dom-attributelist-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.10 Text and CDATASection (dom-text-objects.html)
---
### 13.6.2.9 Comment Objects
Comment represents a comment in the XML document. It is a
subclass of Node, but cannot have child nodes.


13.6.3 Conformance

dom-exceptions.html | module-xml.dom.html | dom-type-mapping.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.12 Exceptions (dom-exceptions.html)
Up:
13.6 xml.dom (module-xml.dom.html)
Next:
13.6.3.1 Type Mapping (dom-type-mapping.html)
---
## 13.6.3 Conformance
This section describes the conformance requirements and relationships
between the Python DOM API, the W3C DOM recommendations, and the OMG
IDL mapping for Python.


13.6.2.5 Document Objects

dom-documenttype-objects.html | node565.html | dom-element-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.4 DocumentType Objects (dom-documenttype-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.6 Element Objects (dom-element-objects.html)
---
### 13.6.2.5 Document Objects
A Document represents an entire XML document, including its
constituent elements, attributes, processing instructions, comments
etc. Remeber that it inherits properties from Node.


13.6.2.4 DocumentType Objects

dom-nodelist-objects.html | node565.html | dom-document-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.3 NodeList Objects (dom-nodelist-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.5 Document Objects (dom-document-objects.html)
---
### 13.6.2.4 DocumentType Objects
Information about the notations and entities declared by a document
(including the external subset if the parser uses it and can provide
the information) is available from a DocumentType object. The
DocumentType for a document is available from the
Document object's doctype attribute; if there is no
`DOCTYPE` declaration for the document, the document's
doctype attribute will be set to `None` instead of an
instance of this interface.
DocumentType is a specialization of Node, and adds the
following attributes:


13.6.2.6 Element Objects

dom-document-objects.html | node565.html | dom-attr-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.5 Document Objects (dom-document-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.7 Attr Objects (dom-attr-objects.html)
---
### 13.6.2.6 Element Objects
Element is a subclass of Node, so inherits all the
attributes of that class.


13.7.2 DOM Example

dom-objects.html | module-xml.dom.minidom.html | minidom-and-dom.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.7.1 DOM Objects (dom-objects.html)
Up:
13.7 xml.dom.minidom (module-xml.dom.minidom.html)
Next:
13.7.3 minidom and the (minidom-and-dom.html)
---
## 13.7.2 DOM Example
This example program is a fairly realistic example of a simple
program. In this particular case, we do not take much advantage
of the flexibility of the DOM.
```text
import xml.dom.minidom

document = """\
<slideshow>
<title>Demo slideshow</title>
<slide><title>Slide title</title>
<point>This is a demo</point>
<point>Of a program for processing slides</point>
</slide>

<slide><title>Another demo slide</title>
<point>It is important</point>
<point>To have more than</point>
<point>one slide</point>
</slide>
</slideshow>
"""

dom = xml.dom.minidom.parseString(document)

def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc

def handleSlideshow(slideshow):
print "<html>"
handleSlideshowTitle(slideshow.getElementsByTagName("title")[0])
slides = slideshow.getElementsByTagName("slide")
handleToc(slides)
handleSlides(slides)
print "</html>"

def handleSlides(slides):
for slide in slides:
handleSlide(slide)

def handleSlide(slide):
handleSlideTitle(slide.getElementsByTagName("title")[0])
handlePoints(slide.getElementsByTagName("point"))

def handleSlideshowTitle(title):
print "<title>%s</title>" % getText(title.childNodes)

def handleSlideTitle(title):
print "<h2>%s</h2>" % getText(title.childNodes)

def handlePoints(points):
print "<ul>"
for point in points:
handlePoint(point)
print "</ul>"

def handlePoint(point):
print "<li>%s</li>" % getText(point.childNodes)

def handleToc(slides):
for slide in slides:
title = slide.getElementsByTagName("title")[0]
print "<p>%s</p>" % getText(title.childNodes)

handleSlideshow(dom)
```
Download as text (original file name: minidom-example.py). (minidom-example.txt)


13.6.2.12 Exceptions

dom-pi-objects.html | node565.html | dom-conformance.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.11 ProcessingInstruction Objects (dom-pi-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.3 Conformance (dom-conformance.html)
---
### 13.6.2.12 Exceptions
New in version 2.1.
The DOM Level 2 recommendation defines a single exception,
DOMException, and a number of constants that allow
applications to determine what sort of error occurred.
DOMException instances carry a code attribute
that provides the appropriate value for the specific exception.
The Python DOM interface provides the constants, but also expands the
set of exceptions so that a specific exception exists for each of the
exception codes defined by the DOM. The implementations must raise
the appropriate specific exception, each of which carries the
appropriate value for the code attribute.
The exception codes defined in the DOM recommendation map to the
exceptions described above according to this table:


13.6.2.1 DOMImplementation Objects

node565.html | node565.html | dom-node-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2 Objects in the (node565.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.2 Node Objects (dom-node-objects.html)
---
### 13.6.2.1 DOMImplementation Objects
The DOMImplementation interface provides a way for
applications to determine the availability of particular features in
the DOM they are using. DOM Level 2 added the ability to create new
Document and DocumentType objects using the
DOMImplementation as well.


13.6.2.2 Node Objects

dom-implementation-objects.html | node565.html | dom-nodelist-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.1 DOMImplementation Objects (dom-implementation-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.3 NodeList Objects (dom-nodelist-objects.html)
---
### 13.6.2.2 Node Objects
All of the components of an XML document are subclasses of
Node.


13.6.2.3 NodeList Objects

dom-node-objects.html | node565.html | dom-documenttype-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.2 Node Objects (dom-node-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.4 DocumentType Objects (dom-documenttype-objects.html)
---
### 13.6.2.3 NodeList Objects
A NodeList represents a sequence of nodes. These objects are
used in two ways in the DOM Core recommendation: the
Element objects provides one as its list of child nodes, and
the getElementsByTagName() and
getElementsByTagNameNS() methods of Node return
objects with this interface to represent query results.
The DOM Level 2 recommendation defines one method and one attribute
for these objects:
In addition, the Python DOM interface requires that some additional
support is provided to allow NodeList objects to be used as
Python sequences. All NodeList implementations must include
support for __len__() and __getitem__(); this allows
iteration over the NodeList in for statements and
proper support for the len() built-in function.
If a DOM implementation supports modification of the document, the
NodeList implementation must also support the
__setitem__() and __delitem__() methods.


13.7.1 DOM Objects

module-xml.dom.minidom.html | module-xml.dom.minidom.html | dom-example.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.7 xml.dom.minidom (module-xml.dom.minidom.html)
Up:
13.7 xml.dom.minidom (module-xml.dom.minidom.html)
Next:
13.7.2 DOM Example (dom-example.html)
---
## 13.7.1 DOM Objects
The definition of the DOM API for Python is given as part of the
xml.dom (module-xml.dom.html) module documentation. This section lists the
differences between the API and xml.dom.minidom (module-xml.dom.minidom.html).
The following standard DOM methods have special considerations with
xml.dom.minidom (module-xml.dom.minidom.html):


13.6.2.11 ProcessingInstruction Objects

dom-text-objects.html | node565.html | dom-exceptions.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.10 Text and CDATASection (dom-text-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.12 Exceptions (dom-exceptions.html)
---
### 13.6.2.11 ProcessingInstruction Objects
Represents a processing instruction in the XML document; this inherits
from the Node interface and cannot have child nodes.


13.6.2.10 Text and CDATASection Objects

dom-comment-objects.html | node565.html | dom-pi-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.2.9 Comment Objects (dom-comment-objects.html)
Up:
13.6.2 Objects in the (node565.html)
Next:
13.6.2.11 ProcessingInstruction Objects (dom-pi-objects.html)
---
### 13.6.2.10 Text and CDATASection Objects
The Text interface represents text in the XML document. If
the parser and DOM implementation support the DOM's XML extension,
portions of the text enclosed in CDATA marked sections are stored in
CDATASection objects. These two interfaces are identical, but
provide different values for the nodeType attribute.
These interfaces extend the Node interface. They cannot have
child nodes.
Note:
The use of a CDATASection node does not indicate that the
node represents a complete CDATA marked section, only that the
content of the node was part of a CDATA section. A single CDATA
section may be represented by more than one node in the document
tree. There is no way to determine whether two adjacent
CDATASection nodes represent different CDATA marked
sections.


13.6.3.1 Type Mapping

dom-conformance.html | dom-conformance.html | dom-accessor-methods.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.6.3 Conformance (dom-conformance.html)
Up:
13.6.3 Conformance (dom-conformance.html)
Next:
13.6.3.2 Accessor Methods (dom-accessor-methods.html)
---
### 13.6.3.1 Type Mapping
The primitive IDL types used in the DOM specification are mapped to
Python types according to the following table.
Additionally, the DOMString defined in the recommendation is
mapped to a Python string or Unicode string. Applications should
be able to handle Unicode whenever a string is returned from the DOM.
The IDL null value is mapped to `None`, which may be
accepted or provided by the implementation whenever null is
allowed by the API.


13.8.1 DOMEventStream Objects

module-xml.dom.pulldom.html | module-xml.dom.pulldom.html | module-xml.sax.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.8 xml.dom.pulldom (module-xml.dom.pulldom.html)
Up:
13.8 xml.dom.pulldom (module-xml.dom.pulldom.html)
Next:
13.9 xml.sax (module-xml.sax.html)
---
## 13.8.1 DOMEventStream Objects


13.10.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
Previous:
13.10.1 ContentHandler Objects (content-handler-objects.html)
Up:
13.10 xml.sax.handler (module-xml.sax.handler.html)
Next:
13.10.3 EntityResolver Objects (entity-resolver-objects.html)
---
## 13.10.2 DTDHandler Objects
DTDHandler instances provide the following methods:


7.14.1 Dumbdbm Objects

module-dumbdbm.html | module-dumbdbm.html | module-zlib.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.14 dumbdbm (module-dumbdbm.html)
Up:
7.14 dumbdbm (module-dumbdbm.html)
Next:
7.15 zlib (module-zlib.html)
---
## 7.14.1 Dumbdbm Objects
In addition to the methods provided by the UserDict.DictMixin class,
dumbdbm objects provide the following methods.


node264.html | module-locale.html | locale-gettext.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
6.26.1 Background, details, hints, (node264.html)
Up:
6.26 locale (module-locale.html)
Next:
6.26.3 Access to message (locale-gettext.html)
---
## 6.26.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.
When Python code uses the locale module to change the locale,
this also affects the embedding application. If the embedding
application doesn't want this to happen, it should remove the
_locale extension module (which does all the work) from the
table of built-in modules in the config.c file, and make sure
that the _locale module is not accessible as a shared library.


13.10.3 EntityResolver Objects

dtd-handler-objects.html | module-xml.sax.handler.html | sax-error-handler.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.10.2 DTDHandler Objects (dtd-handler-objects.html)
Up:
13.10 xml.sax.handler (module-xml.sax.handler.html)
Next:
13.10.4 ErrorHandler Objects (sax-error-handler.html)
---
## 13.10.3 EntityResolver Objects


7.5.5 Event Objects

semaphore-examples.html | module-threading.html | thread-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
7.5.4.1 Semaphore Example (semaphore-examples.html)
Up:
7.5 threading (module-threading.html)
Next:
7.5.6 Thread Objects (thread-objects.html)
---
## 7.5.5 Event Objects
This is one of the simplest mechanisms for communication between
threads: one thread signals an event and other threads wait 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.21.1 Examples

module-imp.html | module-imp.html | module-pkgutil.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
3.21 imp (module-imp.html)
Up:
3.21 imp (module-imp.html)
Next:
3.22 pkgutil (module-pkgutil.html)
---
## 3.21.1 Examples
The following function emulates what was the standard import statement
up to Python 1.4 (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.5.4 Content Model Descriptions

expat-example.html | module-xml.parsers.expat.html | expat-errors.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.5.3 Example (expat-example.html)
Up:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Next:
13.5.5 Expat error constants (expat-errors.html)
---
## 13.5.4 Content Model Descriptions
Content modules are described using nested tuples. Each tuple
contains four values: the type, the quantifier, the name, and a tuple
of children. Children are simply additional content module
descriptions.
The values of the first two fields are constants defined in the
`model` object of the xml.parsers.expat module. These
constants can be collected in two groups: the model type group and the
quantifier group.
The constants in the model type group are:
The constants in the quantifier group are:


13.5.5 Expat error constants

expat-content-models.html | module-xml.parsers.expat.html | module-xml.dom.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.5.4 Content Model Descriptions (expat-content-models.html)
Up:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Next:
13.6 xml.dom (module-xml.dom.html)
---
## 13.5.5 Expat error constants
The following constants are provided in the `errors` object of
the xml.parsers.expat (module-xml.parsers.expat.html) module. These constants are useful
in interpreting some of the attributes of the ExpatError
exception objects raised when an error has occurred.
The `errors` object has the following attributes:


13.5.3 Example

expaterror-objects.html | module-xml.parsers.expat.html | expat-content-models.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.5.2 ExpatError Exceptions (expaterror-objects.html)
Up:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Next:
13.5.4 Content Model Descriptions (expat-content-models.html)
---
## 13.5.3 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>""", 1)
```
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: '\n'
Start element: child2 {'name': 'fred'}
Character data: 'More text'
End element: child2
Character data: '\n'
End element: parent
```


13.5.2 ExpatError Exceptions

xmlparser-objects.html | module-xml.parsers.expat.html | expat-example.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
13.5.1 XMLParser Objects (xmlparser-objects.html)
Up:
13.5 xml.parsers.expat (module-xml.parsers.expat.html)
Next:
13.5.3 Example (expat-example.html)
---
## 13.5.2 ExpatError Exceptions
ExpatError exceptions have a number of interesting
attributes:


11.20.5 Fault Objects

binary-objects.html | module-xmlrpclib.html | protocol-error-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.20.4 Binary Objects (binary-objects.html)
Up:
11.20 xmlrpclib (module-xmlrpclib.html)
Next:
11.20.6 ProtocolError Objects (protocol-error-objects.html)
---
## 11.20.5 Fault Objects
A Fault object encapsulates the content of an XML-RPC fault tag.
Fault objects have the following members:


11.5.15 FileHandler Objects

https-handler-objects.html | module-urllib2.html | ftp-handler-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
11.5.14 HTTPSHandler Objects (https-handler-objects.html)
Up:
11.5 urllib2 (module-urllib2.html)
Next:
11.5.16 FTPHandler Objects (ftp-handler-objects.html)
---
## 11.5.15 FileHandler Objects


20.4.2 Form Objects

node720.html | module-fl.html | forms-objects.html | Python Library Reference | contents.html | modindex.html | genindex.html
Previous:
20.4.1 Functions Defined in (node720.html)
Up:
20.4 fl (module-fl.html)
Next:
20.4.3 FORMS Objects (forms-objects.html)
---
## 20.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
Previous:
12.1.1 The Formatter Interface (formatter-interface.html)
Up:
12.1 formatter (module-formatter.html)
Next:
12.1.3 The Writer Interface (writer-interface.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.