code: def pushd(path):
      
      saved = os.getcwd()
      os.chdir(path)
      try:
          yield saved
      finally:
          os.chdir(saved)
docs: A context that enters a given directory and restores the old state on exit.
  
          The original directory is returned as the context variable.