Popular recipes by Christoph Schueler http://code.activestate.com/recipes/users/4174094/2014-05-29T18:48:28-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>