def change_attr(o, name, new_val):
    """Change the attr `name` in `o` with `new_val` if it exists and return the old value"""
    old = getattr(o, name, None)
    if hasattr(o, 'name'):
        setattr(o, name, new_val)
    return o, old, hasattr(o, 'name')
