<div dir="ltr"><div><div><div><div>It was my impression that inversion and injection were really closely related, based on various Fowler talks, including this canonical essay: <a href="https://martinfowler.com/articles/injection.html">https://martinfowler.com/articles/injection.html</a><br><br></div>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: <a href="http://sans-io.readthedocs.io/">http://sans-io.readthedocs.io/</a><br><br></div>For a very basic example, consider this JSONLines (<a href="http://jsonlines.org">jsonlines.org</a>) iterator: <a href="http://boltons.readthedocs.io/en/latest/jsonutils.html">http://boltons.readthedocs.io/en/latest/jsonutils.html</a><br><br></div>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!<br><br></div><div>Mahmoud<br></div><div><br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 26, 2017 at 3:54 PM, Alex Martelli via Baypiggies <span dir="ltr"><<a href="mailto:baypiggies@python.org" target="_blank">baypiggies@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I see you're getting answers on dependency *injection* (on which I would suggest my talk, slides at <a href="http://www.aleax.it/yt_pydi.pdf" target="_blank">http://www.aleax.it/yt_<wbr>pydi.pdf</a> -- 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 <a href="https://www.lynda.com/Programming-Languages-tutorials/Introduction-dependency-inversion/471978/502206-4.html" target="_blank">https://www.lynda.com/<wbr>Programming-Languages-<wbr>tutorials/Introduction-<wbr>dependency-inversion/471978/<wbr>502206-4.html</a> .<span class="HOEnZb"><font color="#888888"><div><br></div><div>Alex</div></font></span></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sun, Feb 26, 2017 at 12:55 PM, Braun Brelin <span dir="ltr"><<a href="mailto:bbrelin@gmail.com" target="_blank">bbrelin@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div>Hi, <br><br></div>Looking for some good examples of Dependency Inversion in Python.  Anyone have any suggestions for sites to look at?<br><br></div>Thanks,<br></div>
<br></div></div><span class="">______________________________<wbr>_________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org" target="_blank">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="https://mail.python.org/mailman/listinfo/baypiggies" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/baypiggies</a><br></span></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="https://mail.python.org/mailman/listinfo/baypiggies" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/baypiggies</a><br></blockquote></div><br></div>