All 23 GoF design patterns as reusable, Pythonic, type-safe implementations.
Project description
pypatterns
All 23 GoF design patterns as reusable, Pythonic, type-safe implementations.
Installation
pip install pypatterns
Requirements
- Python 3.12+
- Zero dependencies
Quick Start
from pypatterns import singleton, Subject, Builder, registry_factory
# Singleton via decorator
@singleton
class Config:
def __init__(self):
self.debug = False
# Observer pattern
subject = Subject[str]()
subject.subscribe(lambda msg: print(f"Got: {msg}"))
subject.notify("hello")
# Factory registry
factory = registry_factory[str, Animal]()
factory.register("dog", lambda: Dog())
factory.register("cat", lambda: Cat())
animal = factory.create("dog")
Patterns Included
Creational
- Singleton, Factory Method, Abstract Factory, Builder, Prototype
Structural
- Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
Behavioral
- Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor
Reference
All patterns follow the catalog at refactoring.guru/design-patterns.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydesignpatterns-0.1.0.tar.gz
(26.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydesignpatterns-0.1.0.tar.gz.
File metadata
- Download URL: pydesignpatterns-0.1.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2be7de7d596660d4456fe1d3e6fc9ea19fb4ce42effd5b22c00bd2605f96c51
|
|
| MD5 |
f1e8109bf27a83f0bd8cf2f88ae2f5dc
|
|
| BLAKE2b-256 |
cee038efa5e41af438382965978daf0aa1b34c2844c5182207c16916814956b2
|
File details
Details for the file pydesignpatterns-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydesignpatterns-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6af6a578db71c900b535ebb747cb9710aebe2c93008ae6acabdc6f8f37da0a66
|
|
| MD5 |
b9624146eed34c93e33ab14a25edad7d
|
|
| BLAKE2b-256 |
03a2be38514735846f6f3b6028f2d90408a4189ad91df7eacd5f4cf6dbd7d516
|