Python Cookbook 2nd Edition

Python Cookbook 2nd Edition: Recipes from the Python Community

Download

Introduction

Organization

Chapter 1, Text, introduction by Fred L. Drake, Jr. This chapter contains recipes for manipulating text in a variety of ways,including combining,filtering,and formatting strings,substituting variables throughout a text document, and dealing with Unicode.

Chapter 2, Files, introduction by Mark Lutz This chapter presents techniques for working with data in files and for manipulating files and directories within the filesystem,including specific file formats and archive formats such as tar and zip.

Chapter 3, Time and Money, introduction by Gustavo Niemeyer and Facundo Batista This chapter (new in this edition) presents tools and techniques for working with dates, times, decimal numbers, and some other money-related issues

Chapter 4, Python Shortcuts, introduction by David Ascher This chapter includes recipes for many common techniques that can be used anywhere,or that don’t really fit into any of the other,more specific recipe categories.

Chapter 5, Searching and Sorting, introduction by Tim Peters This chapter covers techniques for searching and sorting in Python. Many of the recipes explore creative uses of the stable and fast list.sort in conjunction with the decorate-sort-undecorate (DSU) idiom (newly built in with Python 2.4), while others demonstrate the power of heapq, bisect,and other Python searching and sorting tools

Chapter 6, Object-Oriented Programming, introduction by Alex Martelli This chapter offers a wide range of recipes that demonstrate the power of objectoriented programming with Python,including fundamental techniques such as delegating and controlling attribute access via special methods,intermediate ones such as the implementation of various design patterns,and some simple but useful applications of advanced concepts,such as custom metaclasses,which are covered in greater depth in Chapter 20.

Chapter 7, Persistence and Databases, introduction by Aaron Watters This chapter presents Python techniques for persistence,including serialization approaches and interaction with various databases.

Chapter 8, Debugging and Testing, introduction by Mark Hammond This chapter includes a collection of recipes that assist with the debugging and testing process,from customizing error logging and traceback information,to unit testing with custom modules, unittest and doctest

Chapter 9, Processes, Threads, and Synchronization, introduction by Greg Wilson This chapter covers a variety of techniques for concurrent programming,including threads, queues, and multiple processes.

Chapter 10, System Administration, introduction by Donn Cave This chapter includes recipes for a number of common system administration tasks,from generating passwords and interacting with the Windows registry,to handling mailbox and web server issues

Chapter 11, User Interfaces, introduction by Fredrik Lundh This chapter contains recipes for common GUI tasks,mostly with Tkinter,but also a smattering of wxPython,Qt,image processing,and GUI recipes specific to Jython (for JVM—Java Virtual Machine),Mac OS X,and IronPython (for dotNET).

Chapter 12, Processing XML, introduction by Paul Prescod This chapter offers techniques for parsing,processing,and generating XML using a variety of Python tools

Chapter 13, Network Programming, introduction by Guido van Rossum This chapter covers a variety of network programming techniques,from writing basic TCP clients and servers to manipulating MIME messages

Chapter 14, Web Programming, introduction by Andy McKay This chapter presents a variety of web-related recipes,including ones for CGI scripting,running a Java servlet with Jython,and accessing the content of web pages

Chapter 15, Distributed Programming, introduction by Jeremy Hylton This chapter provides recipes for using Python in simple distributed systems, including XML-RPC, CORBA, and Twisted’s Perspective Broker

Chapter 16, Programs About Programs, introduction by Paul F. Dubois This chapter contains Python techniques that involve program introspection, currying, dynamic importing, distributing programs, lexing and parsing

Chapter 17, Extending and Embedding, introduction by David Beazley This chapter offers techniques for extending Python and recipes that assist in the development of extensions

Chapter 18, Algorithms, introduction by Tim Peters This chapter provides a collection of fascinating and useful algorithms and data structures implemented in Python.

Chapter 19, Iterators and Generators, introduction by Raymond Hettinger This chapter (new in this edition) contains recipes demonstrating the variety and power of iterators and generators—how Python makes your loops’ structures simpler, faster, and reusable

Chapter 20, Descriptors, Decorators, and Metaclasses, introduction by Raymond Hettinger This chapter (new in this edition) provides an in-depth look into the infrastructural elements which make Python’s OOP so powerful and smooth,and how you can exploit and customize them for fun and profit. From handy idioms for building properties,to aliasing and caching attributes,all the way to decorators which optimize your functions by hacking their bytecode and to a factory of custom metaclasses to solve metatype conflicts,this chapter shows how,while surely “there be dragons here,” they’re the wise, powerful and beneficent Chinese variety thereof...!

Share This