Python Patterns v1.0.0

A collection of design patterns and idioms in Python

Creational, Structural, and Behavioral patterns with implementations.

Python Design Patterns Creational Structural Behavioral

Python Patterns — a collection of design patterns and idioms in Python. Includes Creational, Structural, and Behavioral patterns with ready-to-use implementations.

PatternDescription
Abstract FactoryUse a generic function with specific factories
BuilderInstead of using multiple constructors, builder receives parameters and returns constructed objects
Factory MethodDelegate a specialized function/method to create instances
PrototypeUse a factory and clones of a prototype for new instances (if instantiation is expensive)
SingletonEnsures that the class has only one instance, and provides a global access point to it

PatternDescription
AdapterConverts the interface of one class to the interface of another that clients expect
BridgeA client-provider middleman to soften interface changes
CompositeLets clients treat individual objects and compositions uniformly
DecoratorWrap functionality with other functionality in order to affect outputs
FacadeUse one class as an API to a number of others
FlyweightTransparently reuse existing instances of objects with similar/identical state
ProxyAn object funnels operations to something else

PatternDescription
BlackboardArchitectural model, assemble different sub-system knowledge to build a solution
Chain Of ResponsibilityApply a chain of successive handlers to try and process the data
CommandBundle a command and arguments to call later
InterpreterA behavioral design pattern that solves a frequently encountered but subject to change problem
IteratorTraverse a container and access the container's elements
MediatorAn object that knows how to connect other objects and act as a proxy
MementoGenerate an opaque token that can be used to go back to a previous state
ObserverProvide a callback for notification of events/changes to data
StateLogic is organized into a discrete number of potential states and the next state that can be transitioned to
StrategySelectable operations over the same data
Template MethodDefines the basis of the algorithm and allows subclasses to override some steps
VisitorInvoke a callback for all items of a collection

By using this software, you agree to the full disclaimer terms.

Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md

License: BSD 3-Clause License