# python设计模式

## 1. 创建型模型

* 简单工厂 [simple\_factory](https://github.com/wklken/py-patterns/blob/master/simple_factory.py)
* 抽象工厂 [abstract\_factory](https://github.com/wklken/py-patterns/blob/master/abstract_factory.py)
* 建造者 [builder](https://github.com/wklken/py-patterns/blob/master/builder.py)
* 工厂方法 [factory\_method](https://github.com/wklken/py-patterns/blob/master/factory_method.py)
* 原型 [prototype](https://github.com/wklken/py-patterns/blob/master/prototype.py)
* 单例 [singleton](https://github.com/wklken/py-patterns/blob/master/singleton.py)

## 2. 结构型模型

* 适配器 [adapter](https://github.com/wklken/py-patterns/blob/master/adapter.py)
* 桥接 [bridge](https://github.com/wklken/py-patterns/blob/master/bridge.py)
* 组合 [composite](https://github.com/wklken/py-patterns/blob/master/composite.py)
* 装饰 [decorator](https://github.com/wklken/py-patterns/blob/master/decorator.py)
* 外观 [facade](https://github.com/wklken/py-patterns/blob/master/facade.py)
* 享元 [flyweight](https://github.com/wklken/py-patterns/blob/master/flyweight.py)
* 代理 [proxy](https://github.com/wklken/py-patterns/blob/master/proxy.py)

## 3. 行为型

* 观察者 [observer](https://github.com/wklken/py-patterns/blob/master/observer.py)
* 模板方法 [abstract](https://github.com/wklken/py-patterns/blob/master/template_method.py)
* 命令 [command](https://github.com/wklken/py-patterns/blob/master/command.py)
* 状态 [state](https://github.com/wklken/py-patterns/blob/master/state.py)
* 责任链 [chain\_of\_responsibility](https://github.com/wklken/py-patterns/blob/master/chain_of_responsibility.py)
* 解释器 [interpreter](https://github.com/wklken/py-patterns/blob/master/interpreter.py)
* 中介者 [mediator](https://github.com/wklken/py-patterns/blob/master/mediator.py)
* 访问者 [visitor](https://github.com/wklken/py-patterns/blob/master/visitor.py)
* 策略 [strategy](https://github.com/wklken/py-patterns/blob/master/strategy.py)
* 备忘录 [memento](https://github.com/wklken/py-patterns/blob/master/memento.py)
* 迭代器 [iterator](https://github.com/wklken/py-patterns/blob/master/iterator.py)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/pattern.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
