code: def work_dir(path):
      '''
      Context menager for executing commands in some working directory.
      Returns to the previous wd when finished.
  
      Usage:
      >>> with work_dir(path):
      ...   subprocess.call('git status')
  
      '''
      starting_directory = os.getcwd()
      try:
          os.chdir(path)
          yield
      finally:
          os.chdir(starting_directoryf work_dir(path):
      '''
      Context menager for executing commands in some working directory.
      Returns to the previous wd when finished.
  
      Usage:
      >>> with work_dir(path):
      ...   subprocess.call('git status')
  
      '''
      starting_directory = os.getcwd()
      try:
          os.chdir(path)
          yield
      finally:
          os.chdir(starting_directory)
docs: Context menager for executing commands in some working directory.
      Returns to the previous wd when finished.
  
      Usage:
      >>> with work_dir(path):
      ...   subprocess.call('git status')