Python Phrasebook: Essential Code and Commands

Book description

Python Phrasebook

Brad Dayley

Essential Code and Commands

Python Phrasebook gives you the code phrases you need to quickly and effectively complete your programming projects in Python.

Concise and Accessible

Easy to carry and easy to use–lets you ditch all those bulky books for one portable guide

Flexible and Functional

Packed with more than 100 customizable code snippets–so you can readily code functional Python in just about any situation

Brad Dayley is a software engineer at Novell, Inc. He has been a system administrator and software developer on the Unix, Windows, Linux, and NetWare platforms for the past 14 years. Brad co-developed an advanced debugging course used to train engineers and customers and is the co-author of several Novell Press books.

Programming / Python

  

Table of contents

  1. Python Phrasebook
    1. About the Author
    2. Acknowledgments
      1. We Want to Hear from You!
      2. Reader Services
    3. Introduction
    4. 1. Understanding Python
        1. Why Use Python?
        2. Invoking the Interpreter
        3. Built-In Types
          1. None
          2. Numbers
          3. Set
          4. Sequences
          5. Mapping
          6. Files
          7. Callable
          8. Modules
        4. Understanding Python Syntax
          1. Using Code Indentation
          2. Creating MultiLine Statements
          3. Quotation
          4. Formatting Strings
          5. Using Python Flow Control Statements
        5. Python Objects, Modules, Classes, and Functions
          1. Using Objects
          2. Using Modules
          3. Understanding Python Classes
          4. Using Functions
          5. Namespaces and Scoping
        6. Error Handling
        7. Using System Tools
          1. os Module
          2. sys Module
          3. platform Module
          4. time Module
    5. 2. Manipulating Strings
        1. Comparing Strings
        2. Joining Strings
        3. Splitting Strings
        4. Searching Strings for Substrings
        5. Search and Replace in Strings
        6. Searching Strings for Specific Endings/Beginnings
        7. Trimming Strings
        8. Aligning/Formatting Strings
        9. Executing Code Inside Strings
        10. Interpolating Variables Inside Strings
        11. Converting Unicode to Local Strings
    6. 3. Managing Data Types
        1. Defining a List
        2. Accessing a List
        3. Slicing a List
        4. Adding and Removing Items in a List
        5. Sorting a List
        6. Using Tuples
        7. Constructing a Dictionary
        8. Adding a Value to a Dictionary
        9. Retrieving a Value from a Dictionary
        10. Slicing a Dictionary
        11. Swapping Keys for Values in a Dictionary
    7. 4. Managing Files
        1. Opening and Closing Files
        2. Reading an Entire File
        3. Reading a Single Line from a File
        4. Accessing Each Word in a File
        5. Writing a File
        6. Determining the Number of Lines in a File
        7. Walking the Directory Tree
        8. Renaming Files
        9. Recursively Deleting Files and Subdirectories
        10. Searching for Files Based on Extension
        11. Creating a TAR File
        12. Extracting a File from a TAR File
        13. Adding Files to a ZIP File
        14. Retrieving Files from a ZIP File
    8. 5. Managing Threads
        1. Starting a New Thread
        2. Creating and Exiting Threads
        3. Synchronizing Threads
        4. Implementing a Multithreaded Priority Queue
        5. Initiating a Timer-Interrupted Thread
    9. 6. Managing Databases
        1. Adding Entries to a DBM File
        2. Retrieving Entries from a DBM File
        3. Updating Entries in a DBM File
        4. Pickling Objects to a File
        5. Unpickling Objects from a File
        6. Storing Objects in a Shelve File
        7. Retrieving Objects from a Shelve File
        8. Changing Objects in a Shelve File
        9. Connecting to a MySQL Database Server
        10. Creating a MySQL Database
        11. Adding Entries to a MySQL Database
        12. Retrieving Entries from a MySQL Database
    10. 7. Implementing Internet Communication
        1. Opening a Server-Side Socket for Receiving Data
        2. Opening a Client-Side Socket for Sending Data
        3. Receiving Streaming Data Using the ServerSocket Module
        4. Sending Streaming Data
        5. Sending Email Using SMTP
        6. Retrieving Email from a POP3 Server
        7. Using Python to Fetch Files from an FTP Server
    11. 8. Processing HTML
        1. Parsing URLs
        2. Opening HTML Documents
        3. Retrieving Links from HTML Documents
        4. Retrieving Images from HTML Documents
        5. Retrieving Text from HTML Documents
        6. Retrieving Cookies in HTML Documents
        7. Adding Quotes to Attribute Values in HTML Documents
    12. 9. Processing XML
        1. Loading an XML Document
        2. Checking for Well-Formed XML Documents
        3. Accessing Child Nodes
        4. Accessing Element Attributes
        5. Adding a Node to a DOM Tree
        6. Removing a Node from a DOM Tree
        7. Searching XML Documents
        8. Extracting Text from XML Documents
        9. Parsing XML Tags
    13. 10. Programming Web Services
        1. Adding HTML to Web Pages Using CGI Scripts
        2. Processing Parameters Passed to CGI Scripts
        3. Creating Self-Posting CGI Scripts
        4. Allowing Users to Upload Files via CGI Scripts
        5. Creating an HTTP Server to Handle GET Requests
        6. Creating an HTTP Server to Handle POST Requests
        7. Creating an HTTP Server to Process CGI Scripts
        8. Sending an HTTP GET Request from a Python Script
        9. Sending an HTTP POST Request from a Python Script
        10. Creating an XML-RPC Server
        11. Creating an XML-RPC Client
        12. Using SOAPpy to Access SOAP Web Services Through a WSDL File

Product information

  • Title: Python Phrasebook: Essential Code and Commands
  • Author(s): Brad Dayley
  • Release date: November 2006
  • Publisher(s): Sams
  • ISBN: None