Top-rated recipes tagged "adapter"http://code.activestate.com/recipes/tags/adapter/top/2016-06-12T15:27:59-07:00ActiveState Code RecipesCreate on-the-fly class adapters with functools.partial (Python) 2014-05-29T18:48:28-07:00Christoph Schuelerhttp://code.activestate.com/recipes/users/4174094/http://code.activestate.com/recipes/578884-create-on-the-fly-class-adapters-with-functoolspar/ <p style="color: grey"> Python recipe 578884 by <a href="/recipes/users/4174094/">Christoph Schueler</a> (<a href="/recipes/tags/adapter/">adapter</a>, <a href="/recipes/tags/namedtuple/">namedtuple</a>, <a href="/recipes/tags/partial/">partial</a>, <a href="/recipes/tags/pattern/">pattern</a>). </p> <p>functools.partial could not only applied to functions it also works with classes. This opens some interesting perspectives, like on-the-fly creation of class adapters, as the following code illustrates.</p> Drive which Python functions are executed via a text file (Python) 2016-06-12T15:27:59-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580681-drive-which-python-functions-are-executed-via-a-te/ <p style="color: grey"> Python recipe 580681 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/adapter/">adapter</a>, <a href="/recipes/tags/configuration/">configuration</a>, <a href="/recipes/tags/dynamic/">dynamic</a>, <a href="/recipes/tags/dynamic_method/">dynamic_method</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/runtime/">runtime</a>). </p> <p>This recipe shows a simple way of externally controlling which Python functions (out out of some) in your program get executed. The control is done at run time, so no code changes to the program are needed, for different choices. The control is done using a text file.</p>