Dynamically pass a function arguments from a dict

Scott David Daniels Scott.Daniels at Acm.Org
Thu Feb 24 10:37:52 EST 2005


Mark McEahern wrote:
> Dan Eloff wrote:
>> How can you determine that func2 will only accept
>> bar and zoo, but not foo and call the function with
>> bar as an argument? 
> 
> Let Python answer the question for you:
> 
> ... <good explanation of how to do this for simple functions.>

Please be aware the "normal" way to do this is go ahead and call
the function.  Many "function wrapping" techniques will fail this
test, and often the code that looks into the guts of a call in
order to do "something clever" will fail when it is pointed at
anything that uses the technique.

Not only does curry:

     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549

not show you what args it accepts, but decorators, a Python 2.4
invention, will typically obscure the interface of the decorated
function.  Since they wrap _any_ function call, they typically
take the most general arguments possible in order to accommodate
the widest range of functions to wrap.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list