Prototype Pattern

I started reading Mark Summerfield's new book Python in Practice. The first section covers object-oriented software design patterns. Everytime I come across an article or a book that goes over patterns I tell myself I need to make a point of illustrating these from my own experiences, as I can never remember all their names. Here's an example of the prototype pattern from a recent bit of code.

Read more...

Tags: pythonpatterns

Python List Comprehensions

A friend, who is learning python, asked me about how he might generate a cross-tab-like view of some data he was working on. A straight forward problem that presented a nice opportunity to demonstrate a couple of python's language features to reduce the number of lines of code as well as to make it more readable.

Read more...

Tags: python

Python Logging

The only "problem" with python's logging module is that it is so configurable and has so many features that it is easy to lose sight of the forest for the trees. This is my standard method and opinion of how to best work with it. No detailed explanations forthcoming. All the "stab yourself in the eye with a fork" details and alternatives are available in the python docs.

Read more...

Tags: python