在 Python 中注入 vs 依赖注入库 [关闭]

问题描述 投票:0回答:1

我正在寻找一个不错的库来在 Python 中实现控制反转和依赖注入。我发现正在测试这 2 个项目,但想问一下您是否对其中任何一个有任何经验或更好的建议:

注入: https://pypi.org/project/Inject/

  • 看起来更简单直接(他们说使用 DI 的“Python”方式)
  • 有点过时(最后一次提交大约 3 年前)
  • Github 中有 544 颗星

依赖注入器: https://python-dependency-injector.ets-labs.org/introduction/index.html

  • 基于容器定义上下文类似Java中的Spring
  • 2 个月前的最后一次提交
  • 2680 开始于 Github
  • 支持与 Fast API 等框架集成

谢谢。

python dependency-injection inversion-of-control
1个回答
0
投票

我们一直在使用的是python-injector,它正在积极开发:https://github.com/python-injector/injector

© www.soinside.com 2019 - 2024. All rights reserved.