@contextmanager
def assuming(*assumptions):
 old_global_assumptions = global_assumptions.copy()
 global_assumptions.update(assumptions)
 try:
  (yield)
 finally:
  global_assumptions.clear()
  global_assumptions.update(old_global_assumptions)

@ contextmanager def assuming ( * assumptions ) : old_global_assumptions = global_assumptions . copy ( ) global_assumptions . update ( assumptions ) try : ( yield ) finally : global_assumptions . clear ( ) global_assumptions . update ( old_global_assumptions )
context manager for assumptions examples .