Popular recipes tagged "injection"http://code.activestate.com/recipes/tags/injection/popular/2010-09-05T17:06:04-07:00ActiveState Code Recipes Keyword Argument Injection with Python Decorators (Python) 2010-09-05T17:06:04-07:00Ahmet Emre Aladağhttp://code.activestate.com/recipes/users/4174877/http://code.activestate.com/recipes/577382-keyword-argument-injection-with-python-decorators/ <p style="color: grey"> Python recipe 577382 by <a href="/recipes/users/4174877/">Ahmet Emre Aladağ</a> (<a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/class_decorator/">class_decorator</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/injection/">injection</a>, <a href="/recipes/tags/variable/">variable</a>). Revision 2. </p> <p>In most of the object oriented codes we write, we need to set class attributes to the given argument values and this is a very line-consuming thing. To get over these redundant lines, I found a solution using decorators. </p> Minimal Dependency Injection Container (Python) 2010-06-05T13:50:03-07:00Alan Franzonihttp://code.activestate.com/recipes/users/4169882/http://code.activestate.com/recipes/577254-minimal-dependency-injection-container/ <p style="color: grey"> Python recipe 577254 by <a href="/recipes/users/4169882/">Alan Franzoni</a> (<a href="/recipes/tags/container/">container</a>, <a href="/recipes/tags/control/">control</a>, <a href="/recipes/tags/dependency/">dependency</a>, <a href="/recipes/tags/di/">di</a>, <a href="/recipes/tags/dic/">dic</a>, <a href="/recipes/tags/injection/">injection</a>, <a href="/recipes/tags/inversion/">inversion</a>, <a href="/recipes/tags/ioc/">ioc</a>, <a href="/recipes/tags/iocc/">iocc</a>). </p> <p>An example of a minimal dependency injection ( aka Inversion of Control ) container for Python.</p> Flipdict -- python dict that also maintains a one-to-one inverse mapping (Python) 2009-12-03T14:43:52-08:00Francis Carrhttp://code.activestate.com/recipes/users/4172444/http://code.activestate.com/recipes/576968-flipdict-python-dict-that-also-maintains-a-one-to-/ <p style="color: grey"> Python recipe 576968 by <a href="/recipes/users/4172444/">Francis Carr</a> (<a href="/recipes/tags/1_to_1/">1_to_1</a>, <a href="/recipes/tags/bijection/">bijection</a>, <a href="/recipes/tags/bijective/">bijective</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/injection/">injection</a>, <a href="/recipes/tags/injective/">injective</a>, <a href="/recipes/tags/inverse/">inverse</a>, <a href="/recipes/tags/invert/">invert</a>, <a href="/recipes/tags/mapping/">mapping</a>, <a href="/recipes/tags/one_to_one/">one_to_one</a>). Revision 6. </p> <p>A Flipdict is a python dict subclass that maintains a one-to-one inverse mapping. Each key maps to a unique value, and each value maps back to that same key. Each instance has a "flip" attribute to access the inverse mapping.</p>