Function to apply superset of arguments to a function

Carl Banks pavlovevidence at gmail.com
Thu Sep 10 05:36:55 CEST 2009


On Sep 9, 8:14 pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
> On Wed, 09 Sep 2009 14:58:22 -0700, Carl Banks wrote:
> > Use case seems perfectly obvious to me.  You have a set of functions
> > that use different strategies to accomplish a task, and there is a lot
> > of overlap in the arguments used but no consistency.  You want to be
> > able to swap in different functions so as to try different strategies
> > (either while editing, or programmatically).  Instead of dealing with
> > arguments that change everytime you want to swap in a different
> > function, you can use this filter and work with a single argument set.
>
> > The example that pops to my mind is numerical optimization.  Many
> > numerical optimizers have similar overall strategies but differ in
> > underlying details, so they will tend to take different options.  An
> > argument filter like the OP wrote would be quite handy here.
>
> Even more handy would be an abstraction layer that gives you a consistent
> API to work with, instead of the fragile and brittle anti-pattern of
> "suppress errors from passing invalid arguments".

It'd be better, but I don't know if it'd be handier.


Carl Banks



More information about the Python-list mailing list