def _set_output(groups, which):
 previous = {}
 try:
  for group in output.expand_aliases(groups):
   previous[group] = output[group]
   output[group] = which
  (yield)
 finally:
  output.update(previous)

def _set_output ( groups , which ) : previous = { } try : for group in output . expand_aliases ( groups ) : previous [ group ] = output [ group ] output [ group ] = which ( yield ) finally : output . update ( previous )
refactored subroutine used by hide and show .