[Baypiggies] Are there any good examples of implementing dependency inversion in Python?

Mahmoud Hashemi mahmoud at hatnote.com
Sun Feb 26 17:10:43 EST 2017


I've got a web microframework with one take on dependency injection:
https://github.com/mahmoud/clastic#dynamic-binding

We used it to great effect at PayPal, but the most recent public use case
was for judging the largest photography competition in the world. Here's
where all the dependencies get sewn together:
https://github.com/hatnote/montage/blob/3f3dd4b61ca191c43de9f4ddf738691175e6adfb/montage/server.py#L134-L169

I was actually quite struck by py.test fixtures when I discovered them,
because the resemblance is a bit uncanny.

Hope that helps!

Mahmoud

On Sun, Feb 26, 2017 at 1:24 PM, Marc Abramowitz <msabramo at gmail.com> wrote:

> I personally haven't seen that pattern used a ton in Python code, compared
> to Java where Spring and such tend to be a very big thing.
>
> The one thing that comes to my mind is the "funcargs" mechanism for
> fixtures in py.test.
>
> http://doc.pytest.org/en/latest/fixture.html
>
> Maybe WSGI could also be considered a form of dependency injection?
>
> I have looked for general DI containers on occasions and there are some
> projects that do that, but I don't think these are very popular.
>
> -Marc
> http://marc-abramowitz.com
> Sent from my iPhone 6+
>
>
> On Feb 26, 2017, at 12:55 PM, Braun Brelin <bbrelin at gmail.com> wrote:
>
> Hi,
>
> Looking for some good examples of Dependency Inversion in Python.  Anyone
> have any suggestions for sites to look at?
>
> Thanks,
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20170226/6b1354ce/attachment.html>


More information about the Baypiggies mailing list