Welcome to the Python Cookbook, a collaborative collection of your
contributions to Python lore.
Python Cookbook code is freely available for use and review. We
encourage you to contribute recipes (code and discussion), comments and
ratings.
Thanks to everyone who submitted recipes and comments for the Python
Cookbook Second Edition. The collection, co-edited with Alex Martelli
and Anna Ravenscroft, is scheduled for publication in March, 2005.
Contributors whose recipes are used in the book will receive a
complimentary copy of the Second Edition. A portion of all royalties
will go to the non-profit Python Software Foundation.
View: |
Editors Pick
|
Approved
|
Not Approved
|
All
|
|
1-20
| 21-40
| 41-60
| 61-80
( found 1814 recipes )
|
<< Previous
|
next >>
|
|
|
|
chain execution of functions using generators
(Vaibhav Bhatia)
This is a simple recipe which uses generators to execute a chain of functions. These functions and ...
Modified: 2006/11/17 21:52
|
|
|
|
|
Yielding out of nested routines by metaclass transformation
(Bernhard Mulder)
Python 2.5 improved the support for generators, making it easier to
use coroutines. If you want to ...
Modified: 2006/11/17 04:16
|
|
|
|
|
one liner frequency count
(Jason Whitlark)
You often see frequency counts done with dicts, requiring serveral lines of code. Here is a way to ... Rated: 3 out of 5 by 2 user(s),
Modified: 2006/11/17 01:07
|
|
|
|
|
one liner frequency count
(Jason Whitlark)
You often see frequency counts done with dicts, requiring serveral lines of code. Here is a way to ... Rated: 3 out of 5 by 2 user(s),
Modified: 2006/11/17 01:07
|
|
|
|
|
A self-cleaning dict-like container which limits the number and lifetime of its items
(Michael Palmer)
This container stores its items both in a dict (for direct access) and in a bi-directionally linked ...
Modified: 2006/11/15 23:51
|
|
|
|
|
JavaScript code compression
(Michael Palmer)
A regex-based kludge for JavaScript code compression. Safely handles string constants and missing ...
Modified: 2006/11/15 17:15
|
|
|
|
|
Yaptoo (Yaptu outrageously obfuscated) - or yet yet another templating utility
(Michael Palmer)
An enhanced version of yaptu, with the following changes
- separated parsing from execution
- ...
Modified: 2006/11/15 16:58
|
|
|
|
|
reduce as a generator
(kay schluehr)
In this recipe the builtin function reduce is generalized to a Python 2.5 style generator called ...
Modified: 2006/11/15 16:36
|
|
|
|
|
Server side JavaScript dependency resolution
(Michael Palmer)
Purpose: Easing maintenance of JavaScript files and their inclusions in web pages by server-side ...
Modified: 2006/11/15 09:53
|
|
|
|
|
New Tail Recursion Decorator
(kay schluehr)
A new tail recursion decorator that eliminates tail calls for recursive functions is introduced. Rated: 4 out of 5 by 4 user(s),
Modified: 2006/11/14 16:04
|
|
|
|
|
An easy password generator using standard Python modules
(hemanth sethuram)
This recipe generates a password of any length using the standard library modules of Python. The ... Rated: 2 out of 5 by 2 user(s),
Modified: 2006/11/12 11:54
|
|
|
|
|
Deeply applying str() across a data structure
(Danny Yoo)
The str() in the standard library behaves in a slightly weird way when applied against lists: on ...
Modified: 2006/11/12 03:23
|
|
|
|
|
Calculate the distance matrix for n-dimensional point array
(Willi Richert)
Three ways to calculate a distance matrix out of a list of n-dimensional points using scipy.
Modified: 2006/11/11 22:56
|
|
|
|
|
A 200-line database engine
(Pierre Quentel)
A fast, in-memory database management program in less than 200 lines
The database object ... Rated: 5 out of 5 by 2 user(s),
Modified: 2006/11/11 11:08
|
|
|
|
|
Examples of algorithm composition with the observer pattern, using generator coroutines
(Jim Baker)
Implements the toposort and strongly_connected_components graph algorithms,
as a demonstration of ...
Modified: 2006/11/10 17:05
|
|
|
|
|
Implementing the observer pattern yet again: this time with coroutines and the with statement
(Jim Baker)
Implements the observer design pattern via generator coroutines, wrapped up to use the new 'with' ...
Modified: 2006/11/10 16:38
|
|
|
|
|
Simple function base Genetic Algorithm
(Ed Blake)
This is a solution to the first problem in this tutorial:
www.ai-junkie.com/ga/intro/gat1.ht...
Modified: 2006/11/09 18:53
|
|
|
|
|
Composite design-pattern using dictionaries
(Anand Pillai)
The recipe illustrates the composite design pattern by using hierarchical dictionaries. It can be ...
Modified: 2006/11/07 08:39
|
|
|
|
|
Lazy Traversal of Directed Graphs
(Vincent Kraeutler)
The os.path.walk routine that ships with the python standard library is limited to traversing the ...
Modified: 2006/11/06 20:34
|
|
|
|
|
LRU cache decorator
(Raymond Hettinger)
One-line decorator call adds caching to functions with hashable arguments and no keyword arguments. ...
Modified: 2006/11/06 00:45
|
|
|
|
|
1-20
| 21-40
| 41-60
| 61-80
( found 1814 recipes )
|
<< Previous
|
next >>
|
|
|
Except where otherwise noted, recipes in the Python Cookbook are
published under the Python license .