set_attr function

Set attributes for named attribute. Appends if attr is NULL