UKUUG home


(the UK's Unix & Open Systems User Group)






Book Discounts

Other Discounts

Mailing lists






Python Cookbook Alex Martelli and David Ascher
Published by O'Reilly and Associates
606 pages
£ 28.50
Published: 29th July 2002
reviewed by John Collins
   in the September 2002 issue (pdf), (html)

This book provides a catalogue of techniques for achieving various tasks in Python.

I approached it as a newcomer to Python, although I know an extremely enthusiastic user of the language who had shown me bits of it before. For those who haven't met it before, Python is yet another interpreted language like Perl and JavaScript. It has control structures which actually rely on the indentation of the program to demarcate blocks. It has Object Orientated features nearer to JavaScript than Perl and it has exception handling more like C++. I like Perl, but I have to admit that it is eccentric as the various built-in functions do not have consistent interfaces which I continually have to check up. Python is much more consistent. However I'm a bit of a fan of Perl's ``unless'' and ``until'' as alternatives to ``if'' and ``while'' and similar, along with the mantra ``There's more than one way to do it''. There's more than one way to do it in Python too, but probably only one really good way.

Except if you need something nearly identical to the examples in this book, you will need to know some basic Python, and I found myself reading the online tutorial at after I had tried to tackle the first few pages. After that the book was easy to understand. I tried many of the more interesting examples (which can be downloaded from the Website given in the preface) on my Linux machine and had some fun adding a few ``frills'' of my own.

The earlier chapters introduce basic ``howtos'' and idioms in Python, not quite in the order understandable to an outright beginner (hence the excursion onto the tutorial) before looking in turn at text handling, file handling, object oriented programming and thread and process management. Next we look at some actual applications, taking in turn systems admin tasks, databases, user interfaces, networking, web programming, and XML handling. Many of the examples, particularly setting up and using sockets and using XML handling functions, looked, I thought, very much neater than the Perl equivalents, but some would say that about all of it.

The book concludes with some more esoteric techniques (debugging only making an appearance here!) and we even have an overview of how to incorporate new C modules into Python. Finally some more complicated algorithms are presented.

All the examples I tried worked fine and were easy to modify. My one grumble might be that two many examples, including the C extensions, were for Windows and not Linux, but they do tell you where to go to get help.

You will need a proper reference manual to go anywhere further and to get started you will need to go to the tutorial and some purists might disdain a book like this but I think people in a hurry to get a job done similar to the ones in this book will find it a handy reference to plunge into the deep end with and learn the language as they go.

Back to reviews list

Tel: 01763 273 475
Fax: 01763 273 255
Web: Webmaster
Queries: Ask Here
Join UKUUG Today!

UKUUG Secretariat
More information

Page last modified 03 Apr 2007
Copyright © 1995-2011 UKUUG Ltd.