anonymous functions/expressions without lambda?

Paul Miller paul at fxtech.com
Thu Apr 28 15:19:02 EDT 2005


Michael Hoffman wrote:
> Dave Benjamin wrote:
> 
>> I think you meant to write something like this:
>>
>> def attrsetter(obj, name, value):
>>     def _return_func():
>>         return setattr(obj, name, value)
>>     return _return_func
> 
> 
> Sure did. Sorry.

You guys have been very helpful!

While on the subject, is there an equivalent for "methodcaller"?

ie. if I want to bind a function which calls a specific method of an 
object with a specific parameter?




More information about the Python-list mailing list