Python Dependency Injection Framework

后端 未结 18 2184
你的背包
你的背包 2020-12-12 14:10

Is there a framework equivalent to Guice (http://code.google.com/p/google-guice) for Python?

相关标签:
18条回答
  • 2020-12-12 14:19

    Here is a small example for a dependency injection container that does constructor injection based on the constructor argument names:

    http://code.activestate.com/recipes/576609-non-invasive-dependency-injection/

    0 讨论(0)
  • 2020-12-12 14:20

    Besides that:

    1. Zope component architekture
    2. pyContainer
    0 讨论(0)
  • 2020-12-12 14:20

    If you just want to do dependency injection in Python, you don't need a framework. Have a look at Dependency Injection the Python Way. It's really quick and easy, and only c. 50 lines of code.

    0 讨论(0)
  • 2020-12-12 14:23

    I haven't used it, but the Spring Python framework is based on Spring and implements Inversion of Control.

    There also appears to be a Guice in Python project: snake-guice

    0 讨论(0)
  • 2020-12-12 14:23

    As an alternative to monkeypatching, I like DI. A nascent project such as http://code.google.com/p/snake-guice/ may fit the bill.

    Or see the blog post Dependency Injection in Python by Dennis Kempin (Aug '08).

    0 讨论(0)
  • 2020-12-12 14:23

    There's dyject (http://dyject.com), a lightweight framework for both Python 2 and Python 3 that uses the built-in ConfigParser

    0 讨论(0)
提交回复
热议问题