Excerpt from Expert Python Programming: Writing a Package in Python

I'm currently reading Expert Python Programming by Tarek Ziadé. I plan on writing a review once I'm done, but in the meantime the publishers over at Packt have kindly sent me an excerpt from the book to publish here. Download "Writing a Package in Python" (PDF)

Generic adapter class in Python

The adapter pattern is often used in programming when you need to adapt one interface to another. Here's a simple generic adapter class that can adapt just about any interface to just about any other. class Adapter(object):     """     Adapts an object by replacing methods.     Usage:     dog = […]

The ebook experience: Packt versus Manning

Last Friday, I bought two new programming books: Expert Python Programming from Packt Publishing, and IronPython in Action from Manning. Although I bought the PDF version of IronPython in Action, I bought the dead-tree version of Expert Python Programming. The reason is because Packt's DRM measures make the PDF version a lot less convenient. Here's […]

The Daily WTF as the optimum way to improve programming ability?

I was listening to a fascinating piece on NPR's Science Friday called The Science of Getting a 'Yes'. The guest speaker, Robert Cialdini, noted that when training firefighters, giving case studies of past mistakes by firefighters was more effective than giving case studies of correct decisions. The point was that negative information is more effective […]

Don’t overuse classes in Python

Unlike some mainstream languages like Java, you don't have to package everything into a class in Python. A class is a good tool when you want to package up state and behavior, but when all you've got is a bundle of related functionality, the module is the natural unit of packaging in Python. In my […]

Getting the selected cells from a wxPython grid

Getting the selected cells from a wxPython grid is a little tricky, because you have to use a different method depending on which of the following scenarios applies: A single cell has been selected Multiple cells have been selected via Control+Clicking A range of cells has been selected via dragging The following two functions will […]