Python Cookbook

Front Cover
Alex Martelli, David Ascher
"O'Reilly Media, Inc.", 2002 - Computers - 574 pages
17 Reviews

ThePython Cookbookis a collection of problems, solutions, and practical examples for Python programmers, written by Python programmers. Over the past year, members of the Python community have contributed material to an online repository of Python recipes hosted by ActiveState. This book contains the best of those recipes, accompanied by overviews and background material by key Python figures.

The recipes in thePython Cookbookrange from simple tasks, such as working with dictionaries and list comprehensions, to entire modules that demonstrate templating systems and network monitoring. This book contains over 200 recipes on the following topics:

  • Searching and sorting
  • Manipulating text
  • Working with files and the filesystem
  • Object-oriented programming
  • Dealing with threads and processes
  • System administration
  • Interacting with databases
  • Creating user interfaces
  • Network and web programming
  • Processing XML
  • Distributed programming
  • Debugging and testing
  • Extending Python

This book is a treasure trove of useful code for all Python programmers, from novices to advanced practitioners, with contributions from such Python luminaries as Guido Van Rossum, David Ascher, Tim Peters, Paul Prescod, Mark Hammond, and Alex Martelli, as well as over 100 other Python programmers. The recipes highlight Python best practices and can be used directly in day-to-day programming tasks, as a source of ideas, or as a way to learn more about Python.

The recipes in thePython Cookbookwere edited by David Ascher, who is on the board of the Python Software Foundation and is the co-author ofLearning Python,and Alex Martelli, who is known for his numerous and exhaustive postings on the Python mailing list. The book contains a foreword by Guido van Rossum, the creator of Python.

  

What people are saying - Write a review

User ratings

5 stars
6
4 stars
6
3 stars
2
2 stars
3
1 star
0

Review: Python Cookbook

User Review  - Chris Sosa - Goodreads

Good as a reference book but not that great otherwise Read full review

Review: Python Cookbook

User Review  - Rakesh - Goodreads

It's just 'okay' as far as a python cookbook is concerned. Aids programming practice, but lacks subtle qualities of a readable text. Read full review

Contents

I
v
II
xiii
III
xvii
IV
1
V
3
VI
4
VII
6
VIII
7
CXXXVI
260
CXXXVII
262
CXXXVIII
264
CXXXIX
267
CXL
269
CXLI
272
CXLII
275
CXLIII
276

IX
8
X
11
XI
13
XII
15
XIII
18
XIV
20
XV
21
XVI
23
XVII
25
XVIII
27
XIX
28
XX
30
XXI
31
XXII
34
XXIII
38
XXIV
40
XXV
42
XXVI
43
XXVII
46
XXVIII
47
XXIX
49
XXX
52
XXXI
54
XXXII
57
XXXIII
59
XXXIV
61
XXXV
63
XXXVI
69
XXXVII
70
XXXVIII
71
XL
72
XLI
74
XLII
76
XLIII
78
XLIV
79
XLV
81
XLVI
83
XLVII
85
XLVIII
86
XLIX
88
L
91
LI
93
LII
94
LIII
96
LIV
97
LV
99
LVI
100
LVII
104
LVIII
109
LIX
113
LX
117
LXI
119
LXIII
121
LXIV
122
LXV
123
LXVI
125
LXVII
127
LXVIII
129
LXIX
132
LXX
134
LXXI
135
LXXII
137
LXXIV
138
LXXV
140
LXXVI
141
LXXVII
143
LXXVIII
144
LXXIX
145
LXXX
146
LXXXI
147
LXXXII
148
LXXXIII
150
LXXXIV
152
LXXXV
154
LXXXVI
156
LXXXVII
160
LXXXVIII
165
LXXXIX
167
XC
169
XCI
172
XCII
174
XCIII
176
XCIV
177
XCV
179
XCVI
182
XCVII
183
XCVIII
186
XCIX
188
C
189
CI
191
CII
193
CIII
194
CIV
198
CV
201
CVI
202
CVII
203
CVIII
206
CIX
208
CX
211
CXI
214
CXII
217
CXIII
218
CXIV
220
CXV
222
CXVI
225
CXVII
227
CXVIII
229
CXIX
231
CXX
233
CXXI
236
CXXII
237
CXXIII
238
CXXIV
240
CXXV
242
CXXVI
243
CXXVII
245
CXXVIII
246
CXXIX
248
CXXX
250
CXXXI
253
CXXXII
254
CXXXIII
255
CXXXIV
257
CXXXV
258
CXLIV
278
CXLV
281
CXLVI
283
CXLVII
285
CXLVIII
287
CXLIX
290
CL
293
CLI
300
CLII
302
CLIII
303
CLIV
305
CLV
306
CLVI
309
CLVII
310
CLVIII
313
CLIX
315
CLX
317
CLXI
319
CLXII
320
CLXIII
324
CLXIV
328
CLXV
330
CLXVI
332
CLXVII
333
CLXVIII
335
CLXIX
336
CLXX
338
CLXXI
339
CLXXII
340
CLXXIII
342
CLXXIV
344
CLXXV
346
CLXXVI
348
CLXXVII
352
CLXXVIII
355
CLXXIX
358
CLXXX
359
CLXXXI
361
CLXXXII
363
CLXXXIII
364
CLXXXIV
366
CLXXXV
368
CLXXXVI
370
CLXXXVII
371
CLXXXVIII
374
CLXXXIX
376
CXC
379
CXCI
381
CXCII
382
CXCIII
384
CXCIV
385
CXCV
386
CXCVI
387
CXCVII
389
CXCVIII
391
CXCIX
392
CC
395
CCI
397
CCII
400
CCIII
404
CCIV
406
CCV
407
CCVI
409
CCVII
411
CCVIII
414
CCIX
416
CCX
419
CCXI
422
CCXII
425
CCXIII
426
CCXIV
427
CCXV
430
CCXVI
431
CCXVII
434
CCXVIII
436
CCXIX
439
CCXX
442
CCXXI
446
CCXXII
451
CCXXIII
454
CCXXIV
456
CCXXV
457
CCXXVI
459
CCXXVII
462
CCXXVIII
463
CCXXIX
465
CCXXX
467
CCXXXI
469
CCXXXII
471
CCXXXIII
473
CCXXXIV
477
CCXXXV
479
CCXXXVI
483
CCXXXVII
487
CCXXXVIII
490
CCXXXIX
491
CCXL
493
CCXLI
496
CCXLII
498
CCXLIII
499
CCXLIV
501
CCXLV
505
CCXLVI
508
CCXLVII
509
CCXLVIII
511
CCXLIX
515
CCL
517
CCLI
519
CCLII
521
CCLIII
523
CCLIV
524
CCLV
526
CCLVI
528
CCLVII
531
CCLVIII
532
CCLIX
534
CCLX
535
CCLXI
537
CCLXII
538
CCLXIII
541
CCLXIV
549
CCLXV
553
Copyright

Common terms and phrases

About the author (2002)

Alex Martelli spent 8 years with IBM Research, winning three Outstanding Technical Achievement Awards. He then spent 13 as a Senior Software Consultant at think3 inc, developing libraries, network protocols, GUI engines, event frameworks, and web access frontends. He has also taught programming languages, development methods, and numerical computing at Ferrara University and other venues. He's a C++ MVP for Brainbench, and a member of the Python Software Foundation. He currently works for AB Strakt, a Python-centered software house in Gteborg, Sweden, mostly by telecommuting from his home in Bologna, Italy. Alex's proudest achievement is the articles that appeared in Bridge World (January/February 2000), which were hailed as giant steps towards solving issues that had haunted contract bridge theoreticians for decades.

David Ascher is the lead for Python projects at ActiveState, including Komodo, ActiveState's integrated development environment written mostly in Python. David has taught courses about Python to corporations, in universities, and at conferences. He also organized the Python track at the 1999 and 2000 O'Reilly Open Source Conventions, and was the program chair for the 10th International Python Conference. In addition, he co-wrote Learning Python (both editions) and serves as a director of the Python Software Foundation. David holds a B.S. in physics and a Ph.D. in cognitive science, both from Brown University.

Bibliographic information