The Adapter Pattern in Python

Interface mismatches are one of the banes of code reuse. You want to integrate component A and component B into your program, but component A expects a method called half_empty() while component B only has a method called half_full(). The Gang of Four (GoF) Adapter pattern is used to convert the interface of an object […]

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 = […]