Paul Miller wrote:
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?

You could use a combination of bound methods and the "curry" function defined in the Python Cookbook:


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

The examples in the discussion do just that.

Dave
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to