use some vars in current context and try rollback state when exit the context.
By default:
from use_context import use
ls = [1, 2, 3]
with use(ls):
ls.append(5)
assert ls == [1, 2, 3]
For use ref (by name):
a = 15
with use(refs=['a']) as ctx:
assert not ctx.is_ref_changed('a')
a = 16
assert a == 16
assert ctx.is_ref_changed('a')
assert a == 15
👍