def make_setter(name, var_type, user_setter):
    """Returns a setter function which sets the attribute `name', first casting
    it to `type' and passing it through the `user_setter' function."""
    return lambda self, new_val: setattr(self, name,
            user_setter(var_type(new_val)))