Preface

We’d like to pretend that ‘Fredrik’ is a role, but even hundreds of volunteers couldn’t possibly keep up. No, ‘Fredrik’ is the result of crossing an http server with a spam filter with an emacs whatsit and some other stuff besides.

Gordon McMillan, June 1998

The Python 2.0 distribution comes with an extensive standard library, comprised of over 200 modules. This book briefly describes each module and provides one or more sample scripts showing how to use it. All in all, this book contains 360 sample scripts.

About This Book

Those people who have nothing better to do than post on the Internet all day long are rarely the ones who have the most insights.

Jakob Nielsen, December 1998

Since I first stumbled upon Python some five years ago, I’ve spent hundreds of hours answering questions on the comp.lang.python newsgroup. Maybe someone found a module that might be exactly what he wanted, but he couldn’t really figure out how to use it. Maybe someone had picked the wrong module for the task. Or maybe someone tried to reinvent the wheel. Often, a short sample script could be much more helpful than a pointer to the reference documentation.

After posting a couple of scripts each week, for a number of years, you end up with a rather large collection of potentially useful scripts. What you’ll find in this book are the best parts from over 3,000 newsgroup messages. You’ll also find hundreds of new scripts added to make sure every little nook and cranny of standard library has been fully covered.

I’ve worked hard to make the scripts both understandable and adaptable. I’ve intentionally kept the annotations as short as possible. If you want more background, there’s plenty of reference material shipped with most Python distributions. In this book, the emphasis is on the code.

Comments, suggestions, and bug reports are welcome. Send them to . I read all mail as soon as it arrives, but it might take a while until I get around to answering.

For updates, addenda, and other information related to this book, point your web browser to http://www.pythonware.com/people/fredrik/librarybook.htm

What About Tkinter?

This book covers the entire standard library, except the (optional) Tkinter user-interface library. There are several reasons for this, mostly related to time, space, and the fact that I’m working on several other Tkinter documentation projects.

For current status on these projects, see http://www.pythonware.com/people/fredrik/tkinterbook.htm.

Production Details

This book was written in DocBook SGML. I used a variety of tools, including Secret Labs’ PythonWorks, Excosoft Documentor, James Clark’s Jade DSSSL processor, Norm Walsh’s DocBook stylesheets, and a bunch of Python scripts, of course.

Thanks to my referees: Tim Peters, Guido van Rossum, David Ascher, Mark Lutz, and Rael Dornfest, and the PythonWare crew: Matthew Ellis, Håkan Karlsson, and Rune Uhlin.

Thanks to Lenny Muellner, who turned my SGML files into the book you see before you, and to Christien Shangraw, who pulled all the different text and code files together for the book and the CD-ROM (view CD-ROM content online at http://examples.oreilly.com/pythonsl).

Get Python Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.