[Baypiggies] Are there any good examples of implementing dependency inversion in Python?
mahmoud at hatnote.com
Sun Feb 26 19:04:07 EST 2017
It was my impression that inversion and injection were really closely
related, based on various Fowler talks, including this canonical essay:
My main takeaway has always been, pass the low-level implementation _into_
the higher level construct, instead of expecting the higher-level wrapper
to create it for you. This is especially visible in Twisted's
Protocol-based approach, now visible in asyncio, and more broadly all the
sans-io libraries: http://sans-io.readthedocs.io/
For a very basic example, consider this JSONLines (jsonlines.org) iterator:
Rather than doing JSONLIterator('target.jsonl') directly, one would do
JSONLIterator(open('target.jsonl')), passing in the open file object (or
any file-like object). Hope that makes sense!
On Sun, Feb 26, 2017 at 3:54 PM, Alex Martelli via Baypiggies <
baypiggies at python.org> wrote:
> I see you're getting answers on dependency *injection* (on which I would
> suggest my talk, slides at http://www.aleax.it/yt_pydi.pdf --
> unfortunately I don't know of a video recording of said talk) while you
> asked about dependency *inversion* (related, but definitely not the same
> thing), for which I don't know of much that's published apart from what a
> search will easily find, such as https://www.lynda.com/
> 502206-4.html .
> On Sun, Feb 26, 2017 at 12:55 PM, Braun Brelin <bbrelin at gmail.com> wrote:
>> Looking for some good examples of Dependency Inversion in Python. Anyone
>> have any suggestions for sites to look at?
>> Baypiggies mailing list
>> Baypiggies at python.org
>> To change your subscription options or unsubscribe:
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies