【问题标题】:Inject vs Dependency injection library in Python在 Python 中注入 vs 依赖注入库
【发布时间】:2023-02-20 20:25:22
【问题描述】:

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

注入: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】:

我们一直在使用的是蟒蛇注射器,正在积极开发中:https://github.com/python-injector/injector

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 2010-09-21
    • 2012-09-23
    • 2010-10-17
    • 2015-02-12
    • 2021-09-11
    相关资源
    最近更新 更多