You are previewing Python Standard Library.
O'Reilly logo
Python Standard Library

Book Description

Python Standard Library is an essential guide for serious Python programmers. Python is a modular language that imports most useful operations from the standard library (basic support modules; operating system interfaces; network protocols; file formats; data conversions; threads and processes; and data storage). You can't really program in Python without using it. In this book, author Fredrik Lundh, creator of the Python Imaging Library (PIL), delivers tested, accurate documentation of all the modules in the Python Standard Library, along with over 300 annotated example scripts using the modules. Python Standard Library renders this valuable information in a clean, easy-to-read format, yet doesn't talk down to readers. This accurate and complete reference documentation is for the Python programmer who wants the facts and little else. The book is based on the author's work with the Python newsgroup: he reviewed more than 2500 questions and answers to that newsgroup in order to make sure the book covered what Python users really wanted to know. An earlier version of this book has been available electronically for over a year, so the material has been tested by Python programmers in real-life applications. This version of Python Standard Library covers all the new modules and related information for Python 2.0, the first new major release of Python in four years.

Table of Contents

  1. Python Standard Library
    1. Preface
      1. About This Book
        1. What About Tkinter?
        2. Production Details
      2. Conventions Used in This Book
      3. About the Examples
      4. How to Contact Us
    2. 1. Core Modules
      1. Introduction
        1. Built-in Functions and Exceptions
        2. Operating System Interface Modules
        3. Type Support Modules
        4. Regular Expressions
        5. Language Support Modules
      2. The _ _builtin_ _ Module
        1. Calling a Function with Arguments from a Tuple or Dictionary
        2. Loading and Reloading Modules
        3. Looking in Namespaces
        4. Checking an Object’s Type
        5. Evaluating Python Expressions
        6. Compiling and Executing Code
        7. Overloading Functions from the _ _builtin_ _ Module
      3. The exceptions Module
      4. The os Module
        1. Working with Files
        2. Working with Directories
        3. Working with File Attributes
        4. Working with Processes
        5. Working with Daemon Processes
      5. The os.path Module
        1. Working with Filenames
        2. Traversing a Filesystem
      6. The stat Module
      7. The string Module
      8. The re Module
      9. The math Module
      10. The cmath Module
      11. The operator Module
      12. The copy Module
      13. The sys Module
        1. Working with Command-line Arguments
        2. Working with Modules
        3. Working with Reference Counts
        4. Checking the Host Platform
        5. Tracing the Program
        6. Working with Standard Input and Output
        7. Exiting the Program
      14. The atexit Module
      15. The time Module
        1. Getting the Current Time
        2. Converting Time Values to Strings
        3. Converting Strings to Time Values
        4. Converting Time Values
        5. Timing Things
      16. The types Module
      17. The gc Module
    3. 2. More Standard Modules
      1. Overview
        1. Files and Streams
        2. Type Wrappers
        3. Random Numbers
        4. Digests and Encryption Algorithms
      2. The fileinput Module
      3. The shutil Module
      4. The tempfile Module
      5. The StringIO Module
      6. The cStringIO Module
      7. The mmap Module
      8. The UserDict Module
      9. The UserList Module
      10. The UserString Module
      11. The traceback Module
      12. The errno Module
      13. The getopt Module
      14. The getpass Module
      15. The glob Module
      16. The fnmatch Module
      17. The random Module
      18. The whrandom Module
      19. The md5 Module
      20. The sha Module
      21. The crypt Module
      22. The rotor Module
      23. The zlib Module
      24. The code Module
    4. 3. Threads and Processes
      1. Overview
        1. Threads
        2. Processes
      2. The threading Module
      3. The Queue Module
      4. The thread Module
      5. The commands Module
      6. The pipes Module
      7. The popen2 Module
      8. The signal Module
    5. 4. Data Representation
      1. Overview
        1. Binary Data
        2. Self-Describing Formats
        3. Output Formatting
        4. Encoded Binary Data
      2. The array Module
      3. The struct Module
      4. The xdrlib Module
      5. The marshal Module
      6. The pickle Module
      7. The cPickle Module
      8. The copy_reg Module
      9. The pprint Module
      10. The repr Module
      11. The base64 Module
      12. The binhex Module
      13. The quopri Module
      14. The uu Module
      15. The binascii Module
    6. 5. File Formats
      1. Overview
        1. Markup Languages
        2. Configuration Files
        3. Archive Formats
      2. The xmllib Module
      3. The xml.parsers.expat Module
      4. The sgmllib Module
      5. The htmllib Module
      6. The htmlentitydefs Module
      7. The formatter Module
      8. The ConfigParser Module
      9. The netrc Module
      10. The shlex Module
      11. The zipfile Module
        1. Listing the Contents
        2. Reading Data from a ZIP File
        3. Writing Data to a ZIP File
      12. The gzip Module
    7. 6. Mail and News Message Processing
      1. Overview
      2. The rfc822 Module
      3. The mimetools Module
      4. The MimeWriter Module
      5. The mailbox Module
      6. The mailcap Module
      7. The mimetypes Module
      8. The packmail Module
      9. The mimify Module
      10. The multifile Module
    8. 7. Network Protocols
      1. Overview
        1. Internet Time Protocol
        2. Hypertext Transfer Protocol
      2. The socket Module
      3. The select Module
      4. The asyncore Module
      5. The asynchat Module
      6. The urllib Module
      7. The urlparse Module
      8. The cookie Module
      9. The robotparser Module
      10. The ftplib Module
      11. The gopherlib Module
      12. The httplib Module
        1. Posting Data to an HTTP Server
      13. The poplib Module
      14. The imaplib Module
      15. The smtplib Module
      16. The telnetlib Module
      17. The nntplib Module
        1. Listing messages
        2. Downloading Messages
      18. The SocketServer Module
      19. The BaseHTTPServer Module
      20. The SimpleHTTPServer Module
      21. The CGIHTTPServer Module
      22. The cgi Module
      23. The webbrowser Module
    9. 8. Internationalization
      1. The locale Module
      2. The unicodedata Module
      3. The ucnhash Module
    10. 9. Multimedia Modules
      1. Overview
      2. The imghdr Module
      3. The sndhdr module
      4. The whatsound Module
      5. The aifc Module
      6. The sunau Module
      7. The sunaudio Module
      8. The wave Module
      9. The audiodev Module
      10. The winsound Module
      11. The colorsys Module
    11. 10. Data Storage
      1. Overview
      2. The anydbm Module
      3. The whichdb Module
      4. The shelve Module
      5. The dbhash Module
      6. The dbm Module
      7. The dumbdbm Module
      8. The gdbm Module
    12. 11. Tools and Utilities
      1. The dis Module
      2. The pdb Module
      3. The bdb Module
      4. The profile Module
      5. The pstats Module
      6. The tabnanny Module
    13. 12. Platform-Specific Modules
      1. Overview
      2. The fcntl Module
      3. The pwd Module
      4. The grp Module
      5. The nis Module
      6. The curses Module
      7. The termios Module
      8. The tty Module
      9. The resource Module
      10. The syslog Module
      11. The msvcrt Module
      12. The nt Module
      13. The _winreg Module
      14. The posix Module
    14. 13. Implementation Support Modules
      1. The dospath Module
      2. The macpath Module
      3. The ntpath Module
      4. The posixpath Module
      5. The strop Module
      6. The imp Module
      7. The new Module
      8. The pre Module
      9. The sre Module
      10. The py_compile Module
      11. The compileall Module
      12. The ihooks Module
      13. The linecache Module
      14. The macurl2path Module
      15. The nturl2path module
      16. The tokenize Module
      17. The keyword Module
      18. The parser Module
      19. The symbol Module
      20. The token Module
    15. 14. Other Modules
      1. Overview
      2. The pyclbr Module
      3. The filecmp Module
      4. The cmd Module
      5. The rexec Module
      6. The Bastion Module
      7. The readline Module
      8. The rlcompleter Module
      9. The statvfs Module
      10. The calendar Module
      11. The sched Module
      12. The statcache Module
      13. The grep Module
      14. The dircache Module
      15. The dircmp Module
      16. The cmp Module
      17. The cmpcache Module
      18. The util Module
      19. The soundex Module
      20. The timing Module
      21. The posixfile Module
      22. The bisect Module
      23. The knee Module
      24. The tzparse Module
      25. The regex Module
      26. The regsub Module
      27. The reconvert Module
      28. The regex_syntax Module
      29. The find Module
    16. Index
    17. Colophon