Python Cookbook 2Nd Edition Jun 1002005 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Python Cookbook 2Nd Edition Jun 1002005 [Electronic resources] - نسخه متنی

David Ascher, Alex Martelli, Anna Ravenscroft

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


Organization


This book has 20 chapters. Each chapter is devoted to a particular
kind of recipe, such as algorithms, text processing, databases, and
so on. The 1st edition had 17 chapters. There have been improvements
to Python, both language and library, and to the corpus of recipes
the Python community has posted to the cookbook site, that convinced
us to add three entirely new chapters: on the iterators and
generators introduced in Python 2.3; on Python's
support for time and money operations, both old and new; and on new,
advanced tools introduced in Python 2.2 and following releases
(custom descriptors, decorators, metaclasses). Each chapter contains
an introduction, written by an expert in the field, followed by
recipes selected from the online cookbook (in some casesabout
5% of this book's recipesa few new recipes
were specially written for this volume) and edited to fit the
book's formatting and style requirements. Alex (with
some help from Anna) did the vast majority of the
selectiondetermining which recipes from the first edition to
keep and update, and selecting new recipes to add, or merge with
others, from the nearly 1,000 available on the site (so, if a recipe
you posted to the cookbook site didn't get into this
printed edition, it's his
fault!). He also decided which subjects just had
to be covered and thus might need specially written
recipesalthough he couldn't manage to get
quite all of the specially written recipes he
wanted, so anything that's missing, and
wasn't on the cookbook site, might not be entirely
his fault.

Once the selection was complete, the work turned to editing the
recipes, and to merging multiple recipes, as well as incorporating
important contents from many significant comments posted about the
recipes. This proved to be quite a challenge, just as it had been for
the first edition, but even more so. The recipes varied widely in
their organization, level of completeness, and sophistication. With
over 300 authors involved, over 300 different
"voices" were included in the text.
We have striven to maintain a variety of styles to reflect the true
nature of this book, the book written by the entire Python community.
However, we edited each recipe, sometimes quite considerably, to make
it as accessible and useful as possible, ensuring enough uniformity
in structure and presentation to maximize the usability of the book
as a whole. Most recipes, both from the first edition and from the
online site, had to be updated, sometimes heavily, to take advantage
of new tools and better approaches developed since those recipes were
originally posted. We also carefully reconsidered (and slightly
altered) the ordering of chapters, and the placement and ordering of
recipes within chapters; our goal in this reordering was to maximize
the book's usefulness for both newcomers to Python
and seasoned veterans, and, also, for both readers tackling the book
sequentially, cover to cover, and ones just dipping in, in
"random access" fashion, to look
for help on some specific area.

While the book should thus definitely be accessible
"by hops and jumps," we
nevertheless believe a first sequential skim will amply repay the
modest time you, the reader, invest in it. On such a skim, skip every
recipe that you have trouble following or that is of no current
interest to you. Despite the skipping, you'll still
get a sense of how the whole book hangs together and of where certain
subjects are covered, which will stand you in good stead both for
later in-depth sequential reading, if that's your
choice, and for "random access"
reading. To further help you get a sense of what's
where in the book, here's a capsule summary of each
chapter's contents, and equally capsule bios of the
Python experts who were so kind as to take on the task of writing the
chapters'
"Introduction" sections.

Chapter 1 , 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.

Fred Drake is a member of the PythonLabs group, working on Python
development. A father of three, Fred is best known in the Python
community for single-handedly maintaining the official documentation.
Fred is a co-author of Python & XML
(O'Reilly).


Chapter 2 , 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.

Mark Lutz is well known to most Python users as the most prolific
author of Python books, including Programming
Python
, Python Pocket Reference, and
Learning Python (all from
O'Reilly), which he co-authored with David Ascher.
Mark is also a leading Python trainer, spreading the Python gospel
throughout the world.


Chapter 3 , 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.

Gustavo Niemeyer is the author of the third-party
dateutil module, as well as a variety of other
Python extensions and projects. Gustavo lives in Brazil. Facundo
Batista is the author of the Decimal PEP 327, and of the standard
library module decimal, which brought
floating-point decimal support to Python 2.4. He lives in Argentina.
The editors were delighted to bring them together for this
introduction.


Chapter 4 , 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.

David Ascher is a co-editor of this volume. David's
background spans physics, vision research, scientific visualization,
computer graphics, a variety of programming languages, co-authoring
Learning Python (O'Reilly),
teaching Python, and these days, a slew of technical and nontechnical
tasks such as managing the ActiveState team. David also gets roped
into organizing Python conferences on a regular basis.


Chapter 5 , 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.

Tim Peters, also known as the tim-bot, is one of
the mythological figures of the Python world. He is the oracle,
channeling Guido van Rossum when Guido is busy, channeling the
IEEE-754 floating-point committee when anyone asks anything remotely
relevant, and appearing conservative while pushing for a constant
evolution in the language. Tim is a member of the PythonLabs team.


Chapter 6 , introduction by Alex Martelli


This chapter offers a wide range of recipes that demonstrate the
power of object-oriented 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 .

Alex Martelli, also known as the martelli-bot,
is a co-editor of this volume. After almost a decade with IBM
Research, then a bit more than that with think3, inc., Alex now works
as a freelance consultant, most recently for AB Strakt, a Swedish
Python-centered firm. He also edits and writes Python articles and
books, including Python in a Nutshell
(O'Reilly) and, occasionally, research works on the
game of contract bridge.


Chapter 7 , introduction by Aaron Watters


This chapter presents Python techniques for persistence, including
serialization approaches and interaction with various databases.

Aaron Watters was one of the earliest advocates of Python and is an
expert in databases. He's known for having been the
lead author on the first book on Python (Internet
Programming with Python
, M&T Books, now out of print),
and he has authored many widely used Python extensions, such as
kjBuckets and kwParsing. Aaron
currently works as a freelance consultant.


Chapter 8 , 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.

Mark Hammond is best known for his work supporting Python on the
Windows platform. With Greg Stein, he built an incredible library of
modules interfacing Python to a wide variety of APIs, libraries, and
component models such as COM. He is also an expert designer and
builder of developer tools, most notably Pythonwin and Komodo.
Finally, Mark is an expert at debugging even the most messy
systemsduring Komodo development, for example, Mark was often
called upon to debug problems that spanned three languages (Python,
C++, JavaScript), multiple threads, and multiple processes. Mark is
also co-author, with Andy Robinson, of Python Programming
on Win32
(O'Reilly).


Chapter 9 , introduction by Greg Wilson


This chapter covers a variety of techniques for concurrent
programming, including threads, queues, and multiple processes.

Greg Wilson writes children's books, as well as
books on parallel programming and data crunching. When
he's not doing that, he's a
contributing editor with Doctor Dobb's
Journal
, an adjunct professor in Computer Science at the
University of Toronto, and a freelance software developer. Greg was
the original driving force behind the Software Carpentry project, and
he recently received a grant from the Python Software Foundation to
develop Pythonic course material for computational scientists and
engineers.


Chapter 10 , 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.

Donn Cave is a software engineer at the University of
Washington's central computer site. Over the years,
Donn has proven to be a fount of information on
comp.lang.python on all matters related to
system calls, Unix, system administration, files, signals, and the
like.


Chapter 11 , 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 JVMJava Virtual Machine),
Mac OS X, and IronPython (for dotNET).

Fredrik Lundh, also known as the eff-bot, is the
CTO of Secret Labs AB, a Swedish Python-focused company providing a
variety of products and technologies. Fredrik is the
world's leading expert on Tkinter (the most popular
GUI toolkit for Python), as well as the main author of the Python
Imaging Library (PIL). He is also the author of Python
Standard Library
(O'Reilly), which is a
good complement to this volume and focuses on the modules in the
standard Python library. Finally, he is a prolific contributor to
comp.lang.python, helping novices and experts
alike.


Chapter 12 , introduction by Paul Prescod


This chapter offers techniques for parsing, processing, and
generating XML using a variety of Python tools.

Paul Prescod is an expert in three technologies: Python, which he
need not justify; XML, which makes sense in a pragmatic world (Paul
is co-author of the XML Handbook, with Charles
Goldfarb, published by Prentice Hall); and Unicode, which somehow
must address some deep-seated desire for pain and confusion that
neither of the other two technologies satisfies. Paul is currently a
product manager at Blast Radius.


Chapter 13 , 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.

Guido created Python, nurtured it throughout its infancy, and is
shepherding its growth. Need we say more?


Chapter 14 , 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.

Andy McKay is the co-founder and vice president of Enfold Systems. In
the last few years, Andy went from being a happy Perl user to a
fanatical Python, Zope, and Plone expert. He wrote the
Definitive Guide to Plone (Apress) and runs the
popular Zope discussion site, http://www.zopezen.org.


Chapter 15 , introduction by Jeremy Hylton


This chapter provides recipes for using Python in simple distributed
systems, including XML-RPC, CORBA, and Twisted's
Perspective Broker.

Jeremy Hylton works for Google. In addition to young twins,
Jeremy's interests including programming language
theory, parsers, and the like. As part of his work for CNRI, Jeremy
worked on a variety of distributed systems.


Chapter 16 , introduction by Paul F. Dubois


This chapter contains Python techniques that involve program
introspection, currying, dynamic importing, distributing programs,
lexing and parsing.

Paul Dubois has been working at the Lawrence Livermore National
Laboratory for many years, building software systems for scientists
working on everything from nuclear simulations to climate modeling.
He has considerable experience with a wide range of scientific
computing problems, as well as experience with language design and
advanced object-oriented programming techniques.


Chapter 17 , introduction by David Beazley


This chapter offers techniques for extending Python and recipes that
assist in the development of extensions.

David Beazley's chief claim to fame is SWIG, an
amazingly powerful hack that lets one quickly wrap C and other
libraries and use them from Python, Tcl, Perl, and myriad other
languages. Behind this seemingly language-neutral tool lies a Python
supporter of the first order, as evidenced by his book,
Python Essential Reference (New Riders). David
Beazley is a fairly sick man (in a good way), leading us to believe
that more scarily useful tools are likely to emerge from his brain.
He's currently inflicting his sense of humor on
computer science students at the University of Chicago.


Chapter 18 , introduction by Tim Peters


This chapter provides a collection of fascinating and useful
algorithms and data structures implemented in Python.

See the discussion of Chapter 5 for information about Tim Peters.


Chapter 19 , introduction by Raymond Hettinger


This chapter (new in this edition) contains recipes demonstrating the
variety and power of iterators and generatorshow Python makes
your loops' structures simpler, faster, and
reusable.

Raymond Hettinger is the creator of the itertools
package, original proposer of generator expressions, and has become a
major contributor to the development of Pythonif you
don't know who originated and implemented some major
novelty or important optimization in the 2.3 and 2.4 releases of
Python, our advice is to bet it was Raymond!


Chapter 20 , 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...!

See the discussion of Chapter 19 for information about Raymond
Hettinger.



/ 394