How about you just call set_attrs with attr_dict = {attr; value} so there is no duplicated code.